From 81c3cc046249fcfd479be6d483836f7f52e1bd7e Mon Sep 17 00:00:00 2001 From: Jordan Newport Date: Wed, 1 Dec 2021 22:31:24 -0700 Subject: [PATCH] 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. --- sublime_music/ui/browse.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sublime_music/ui/browse.py b/sublime_music/ui/browse.py index 21d2fe1..376c806 100644 --- a/sublime_music/ui/browse.py +++ b/sublime_music/ui/browse.py @@ -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 = [ [ (