UI: Sort songs by track number in Browse mode

This commit may address issue #287. It simply takes the list of songs
provided by the server in Browse mode and sorts it by disc and track
number. Tests seem to have passed except for (unrelated?) mypy issues.
This commit is contained in:
Jordan Newport
2021-12-01 22:31:24 -07:00
parent c0c76fde17
commit 81c3cc0462

View File

@@ -377,6 +377,14 @@ class MusicDirectoryList(Gtk.Box):
self.drilldown_directories_store, new_directories_store
)
def song_sort_key(song: API.Song):
return (
song.disc_number if hasattr(song, "disc_number") else 0,
song.track if hasattr(song, "track") else 0,
)
songs.sort(key=song_sort_key)
new_songs_store = [
[
(