diff --git a/qubes/__init__.py b/qubes/__init__.py index 36aad18c..ff8d0d1d 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -333,7 +333,7 @@ class Label(object): def __xml__(self): element = lxml.etree.Element( - 'label', id='label-' + self.index, color=self.color) + 'label', id='label-{}'.format(self.index), color=self.color) element.text = self.name return element @@ -1285,7 +1285,7 @@ class Qubes(PropertyHolder): ''' labels = lxml.etree.Element('labels') - for label in self.labels: + for label in sorted(self.labels.values(), key=lambda labl: labl.index): labels.append(label.__xml__()) return labels