Add slow sort to SmartArtistSort

This commit is contained in:
Adrian Sampson 2014-09-15 19:49:05 -07:00
parent f9c6dd6d67
commit f5e1846ff0

View file

@ -163,6 +163,13 @@ class SmartArtistSort(dbcore.query.Sort):
'WHEN "" THEN {0} '
'ELSE {0}_sort END) {1}').format(field, order)
def sort(self, objs):
if 'albumartist' in self.model_cls._fields:
key = lambda a: a.albumartist_sort or a.albumartist
else:
key = lambda i: i.artist_sort or i.artist
return sorted(objs, key=key)
# Special path format key.
PF_KEY_DEFAULT = 'default'