mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 22:41:48 +01:00
Actually compare chapter numbers as numbers when sorting (fixes #7247)
(cherry picked from commit da8669c826
)
This commit is contained in:
parent
f00e03e5ea
commit
b635789740
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.util.chapter
|
|||||||
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
|
||||||
|
|
||||||
fun getChapterSort(manga: Manga, sortDescending: Boolean = manga.sortDescending()): (Chapter, Chapter) -> Int {
|
fun getChapterSort(manga: Manga, sortDescending: Boolean = manga.sortDescending()): (Chapter, Chapter) -> Int {
|
||||||
return when (manga.sorting) {
|
return when (manga.sorting) {
|
||||||
@ -11,13 +10,13 @@ fun getChapterSort(manga: Manga, sortDescending: Boolean = manga.sortDescending(
|
|||||||
false -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) }
|
false -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) }
|
||||||
}
|
}
|
||||||
Manga.CHAPTER_SORTING_NUMBER -> when (sortDescending) {
|
Manga.CHAPTER_SORTING_NUMBER -> when (sortDescending) {
|
||||||
true -> { c1, c2 -> c2.chapter_number.toString().compareToCaseInsensitiveNaturalOrder(c1.chapter_number.toString()) }
|
true -> { c1, c2 -> c2.chapter_number.compareTo(c1.chapter_number) }
|
||||||
false -> { c1, c2 -> c1.chapter_number.toString().compareToCaseInsensitiveNaturalOrder(c2.chapter_number.toString()) }
|
false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
|
||||||
}
|
}
|
||||||
Manga.CHAPTER_SORTING_UPLOAD_DATE -> when (sortDescending) {
|
Manga.CHAPTER_SORTING_UPLOAD_DATE -> when (sortDescending) {
|
||||||
true -> { c1, c2 -> c2.date_upload.compareTo(c1.date_upload) }
|
true -> { c1, c2 -> c2.date_upload.compareTo(c1.date_upload) }
|
||||||
false -> { c1, c2 -> c1.date_upload.compareTo(c2.date_upload) }
|
false -> { c1, c2 -> c1.date_upload.compareTo(c2.date_upload) }
|
||||||
}
|
}
|
||||||
else -> throw NotImplementedError("Unimplemented sorting method")
|
else -> throw NotImplementedError("Invalid chapter sorting method: ${manga.sorting}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user