[gnome-music/wip/mschraal/core] coremodel: Improve song sort



commit 24a563a26ae3a16acab3f4acc2f775707263fcdf
Author: Marinus Schraal <mschraal gnome org>
Date:   Fri Jun 28 20:45:09 2019 +0200

    coremodel: Improve song sort

 gnomemusic/songliststore.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/songliststore.py b/gnomemusic/songliststore.py
index a2a45b28..f8fdb4e7 100644
--- a/gnomemusic/songliststore.py
+++ b/gnomemusic/songliststore.py
@@ -38,7 +38,19 @@ class SongListStore(Gtk.ListStore):
         return wrap
 
     def _songs_sort(self, song_a, song_b):
-        return song_a.props.title.lower() > song_b.props.title.lower()
+        title_a = song_a.props.title.casefold()
+        title_b = song_b.props.title.casefold()
+        song_cmp = title_a == title_b
+        if not song_cmp:
+            return title_a > title_b
+
+        artist_a = song_a.props.artist.casefold()
+        artist_b = song_b.props.artist.casefold()
+        artist_cmp = artist_a == artist_b
+        if not artist_cmp:
+            return artist_a > artist_b
+
+        return song_a.props.album.casefold() > song_b.props.album.casefold()
 
     def _on_items_changed(self, model, position, removed, added):
         if removed > 0:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]