[gnome-music/wip/mschraal/core: 136/164] coremodel: Improve song sort
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gnome-music/wip/mschraal/core: 136/164] coremodel: Improve song sort
- Date: Mon,  1 Jul 2019 13:49:36 +0000 (UTC)
commit 8da69e8dcb86c9c730febe6451842ec8d5e8e42d
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]