sort: fix sort bug with same-year album songs
Fix a problem where given two albums with the same year, like this: Album 1 [2018] - Song 1 - Song 2 Album 2 [2018] - Song 3 - Song 4 getSortedArtistSongs would incorrectly drop songs that came from any albums that came after Album 1, resulting in this: Song 1 [Album 1] Song 2 [Album 1] This was caused by a quirk in toSortedMap that would drop any map entries that corresponded to a previous sorted entry. We now get and sort the entries directly instead, which fixes the issue.
This commit is contained in:
@@ -144,8 +144,8 @@ enum class SortMode(@DrawableRes val iconRes: Int) {
|
|||||||
NUMERIC_UP -> {
|
NUMERIC_UP -> {
|
||||||
val list = mutableListOf<Song>()
|
val list = mutableListOf<Song>()
|
||||||
|
|
||||||
songs.groupBy { it.album }.toSortedMap(compareBy { it.year }).values.forEach { items ->
|
songs.groupBy { it.album }.entries.sortedBy { it.key.year }.forEach { entry ->
|
||||||
list.addAll(items.sortedWith(compareBy { it.track }))
|
list.addAll(entry.value.sortedWith(compareBy { it.track }))
|
||||||
}
|
}
|
||||||
|
|
||||||
list
|
list
|
||||||
@@ -154,8 +154,8 @@ enum class SortMode(@DrawableRes val iconRes: Int) {
|
|||||||
NUMERIC_DOWN -> {
|
NUMERIC_DOWN -> {
|
||||||
val list = mutableListOf<Song>()
|
val list = mutableListOf<Song>()
|
||||||
|
|
||||||
songs.groupBy { it.album }.toSortedMap(compareByDescending { it.year }).values.forEach { items ->
|
songs.groupBy { it.album }.entries.sortedWith(compareByDescending { it.key.year }).forEach { entry ->
|
||||||
list.addAll(items.sortedWith(compareBy { it.track }))
|
list.addAll(entry.value.sortedWith(compareBy { it.track }))
|
||||||
}
|
}
|
||||||
|
|
||||||
list
|
list
|
||||||
|
|||||||
Reference in New Issue
Block a user