From 70ee0f1681b2495bc429d3ff9af3b947408e4b70 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 1 Nov 2011 22:46:46 +0100 Subject: [PATCH] implement __lt__ to support sorting a list of objects Signed-off-by: Steven Armstrong --- lib/cdist/core/object.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cdist/core/object.py b/lib/cdist/core/object.py index 5157d86a..29dc16e9 100644 --- a/lib/cdist/core/object.py +++ b/lib/cdist/core/object.py @@ -115,6 +115,10 @@ class Object(object): """define equality as 'attributes are the same'""" return self.__dict__ == other.__dict__ + def __lt__(self, other): + return isinstance(other, self.__class__) and self.name < other.name + + # FIXME: still needed? @property def explorer_path(self):