def _playlists_sort(self, playlist_a, playlist_b): if playlist_a.props.is_smart: if not playlist_b.props.is_smart: return -1 return utils.natural_sort_names(playlist_a.props.title, playlist_b.props.title) if playlist_b.props.is_smart: return 1 # cannot use GLib.DateTime.compare # https://gitlab.gnome.org/GNOME/pygobject/issues/334 # newest first date_diff = playlist_b.props.creation_date.difference( playlist_a.props.creation_date) return math.copysign(1, date_diff)
def _artist_sort(self, artist_a, artist_b): return utils.natural_sort_names(artist_a.props.artist, artist_b.props.artist)
def _albums_sort(self, album_a, album_b): return utils.natural_sort_names(album_a.props.title, album_b.props.title)