Skip to content

Commit 0e3db43

Browse files
ignore cases in hard coded sorting
1 parent 9d40a66 commit 0e3db43

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

lib/src/beginning/utilities/page_backend/artists_back.dart

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,18 @@ artistsAllSongs(String who) async {
6060
int order = (musicBox.get('artistSort') ?? [0, 3])[1];
6161
if (sort == 0) {
6262
//TITLE
63-
inArtistsSongs.sort((a, b) => a.title.compareTo(b.title));
63+
inArtistsSongs
64+
.sort((a, b) => a.title.toLowerCase().compareTo(b.title.toLowerCase()));
6465
} else if (sort == 1) {
6566
//DATE
6667
inArtistsSongs
6768
.sort((a, b) => (a.dateAdded ?? 0).compareTo((b.dateAdded ?? 0)));
6869
} else {
6970
//ALBUM
70-
inArtistsSongs.sort((a, b) => (a.album ?? "").compareTo((b.album ?? "")));
71+
inArtistsSongs.sort((a, b) =>
72+
(a.album ?? "").toLowerCase().compareTo((b.album ?? "").toLowerCase()));
7173
}
72-
if (order == 3) {
73-
//ASCENDING
74-
if (sort == 0) {
75-
//TITLE
76-
inArtistsSongs.sort((a, b) => a.title.compareTo(b.title));
77-
} else if (sort == 1) {
78-
//DATE
79-
inArtistsSongs
80-
.sort((a, b) => (a.dateAdded ?? 0).compareTo((b.dateAdded ?? 0)));
81-
} else {
82-
//ALBUM
83-
inArtistsSongs.sort((a, b) => (a.album ?? "").compareTo((b.album ?? "")));
84-
}
85-
} else {
74+
if (order == 4) {
8675
//DESCENDING
8776
inArtistsSongs = inArtistsSongs.reversed.toList();
8877
}

lib/src/beginning/utilities/page_backend/genres_back.dart

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,21 @@ fetchGenreSongs(int index) async {
6464
int order = (musicBox.get('genreSort') ?? [0, 4])[1];
6565
genreSongs = insideAllGenreData.values.toList()[index];
6666
if (sort == 0) {
67-
genreSongs!.sort((a, b) => a.title.compareTo(b.title));
67+
genreSongs!.sort(
68+
(a, b) => a.title.toLowerCase().compareTo(b.title.toLowerCase()));
6869
} else if (sort == 1) {
6970
genreSongs!
7071
.sort((a, b) => (a.dateAdded ?? 0).compareTo((b.dateAdded ?? 0)));
7172
} else if (sort == 2) {
72-
genreSongs!.sort((a, b) => (a.album ?? "").compareTo((b.album ?? "")));
73+
genreSongs!.sort((a, b) => (a.album ?? "")
74+
.toLowerCase()
75+
.compareTo((b.album ?? "").toLowerCase()));
7376
} else {
74-
genreSongs!.sort((a, b) => (a.artist ?? "").compareTo((b.artist ?? "")));
77+
genreSongs!.sort((a, b) => (a.artist ?? "")
78+
.toLowerCase()
79+
.compareTo((b.artist ?? "").toLowerCase()));
7580
}
76-
if (order == 0) {
77-
if (sort == 0) {
78-
genreSongs!.sort((a, b) => a.title.compareTo(b.title));
79-
} else if (sort == 1) {
80-
genreSongs!
81-
.sort((a, b) => (a.dateAdded ?? 0).compareTo((b.dateAdded ?? 0)));
82-
} else if (sort == 2) {
83-
genreSongs!.sort((a, b) => (a.album ?? "").compareTo((b.album ?? "")));
84-
} else {
85-
genreSongs!
86-
.sort((a, b) => (a.artist ?? "").compareTo((b.artist ?? "")));
87-
}
88-
} else {
81+
if (order == 5) {
8982
genreSongs = genreSongs!.reversed.toList();
9083
}
9184
} else {

0 commit comments

Comments
 (0)