瀏覽代碼

Use natural ordering when sorting by chapter numbers (fixes #6121)

arkon 3 年之前
父節點
當前提交
f057440cc1
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt

+ 3 - 2
app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt

@@ -2,6 +2,7 @@ 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) {
@@ -10,8 +11,8 @@ 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.compareTo(c1.chapter_number) }
-            false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
+            true -> { c1, c2 -> c2.chapter_number.toString().compareToCaseInsensitiveNaturalOrder(c1.chapter_number.toString()) }
+            false -> { c1, c2 -> c1.chapter_number.toString().compareToCaseInsensitiveNaturalOrder(c2.chapter_number.toString()) }
         }
         }
         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) }