- def __cmp__(self, other):
- c = cmp(self.score, other.score)
- if c == 0:
- # this is inverted, because earlier date is better
- return cmp(other.published_date, self.published_date)
- else:
- return c
+ def get_sort_key(self):
+ return (-self.score,
+ self.published_date,
+ self.book.sort_key_author if self.book else '',
+ self.book.sort_key if self.book else '')
+
+ def __lt__(self, other):
+ return self.get_sort_key() > other.get_sort_key()
+
+ def __eq__(self, other):
+ return self.get_sort_key() == other.get_sort_key()