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:
parent
1a0ff53d67
commit
58bea1dda5
1 changed files with 4 additions and 4 deletions
|
|
@ -144,8 +144,8 @@ enum class SortMode(@DrawableRes val iconRes: Int) {
|
|||
NUMERIC_UP -> {
|
||||
val list = mutableListOf<Song>()
|
||||
|
||||
songs.groupBy { it.album }.toSortedMap(compareBy { it.year }).values.forEach { items ->
|
||||
list.addAll(items.sortedWith(compareBy { it.track }))
|
||||
songs.groupBy { it.album }.entries.sortedBy { it.key.year }.forEach { entry ->
|
||||
list.addAll(entry.value.sortedWith(compareBy { it.track }))
|
||||
}
|
||||
|
||||
list
|
||||
|
|
@ -154,8 +154,8 @@ enum class SortMode(@DrawableRes val iconRes: Int) {
|
|||
NUMERIC_DOWN -> {
|
||||
val list = mutableListOf<Song>()
|
||||
|
||||
songs.groupBy { it.album }.toSortedMap(compareByDescending { it.year }).values.forEach { items ->
|
||||
list.addAll(items.sortedWith(compareBy { it.track }))
|
||||
songs.groupBy { it.album }.entries.sortedWith(compareByDescending { it.key.year }).forEach { entry ->
|
||||
list.addAll(entry.value.sortedWith(compareBy { it.track }))
|
||||
}
|
||||
|
||||
list
|
||||
|
|
|
|||
Loading…
Reference in a new issue