mirror of https://github.com/patacrep/patacrep.git
Louis
11 years ago
2 changed files with 23 additions and 26 deletions
@ -0,0 +1,23 @@ |
|||
def __cmp__(self, other): |
|||
if not isinstance(other, Song): |
|||
return NotImplemented |
|||
for key in self.sort: |
|||
if key == "@title": |
|||
self_key = self.normalized_titles |
|||
other_key = other.normalized_titles |
|||
elif key == "@path": |
|||
self_key = locale.strxfrm(self.path) |
|||
other_key = locale.strxfrm(other.path) |
|||
elif key == "by": |
|||
self_key = self.normalized_authors |
|||
other_key = other.normalized_authors |
|||
else: |
|||
self_key = locale.strxfrm(self.args.get(key, "")) |
|||
other_key = locale.strxfrm(other.args.get(key, "")) |
|||
|
|||
if self_key < other_key: |
|||
return -1 |
|||
elif self_key > other_key: |
|||
return 1 |
|||
return 0 |
|||
|
Loading…
Reference in new issue