From 42accebeca515c0c0f204612296ad1efa7ea2b13 Mon Sep 17 00:00:00 2001 From: FourTOne5 <59261191+FourTOne5@users.noreply.github.com> Date: Sat, 25 Dec 2021 01:55:11 +0600 Subject: [PATCH] Case insensitive sort in extension list. (#6375) * Sort Extension irrespective of it's name's case. * Avoid creating unnecessary strings Co-Authored-By: arkon Co-authored-by: arkon --- .../ui/browse/extension/ExtensionPresenter.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt index 2980d6f6f..31ffcc0dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt @@ -63,9 +63,15 @@ open class ExtensionPresenter( val items = mutableListOf() - val updatesSorted = installed.filter { it.hasUpdate && (showNsfwSources || !it.isNsfw) }.sortedBy { it.name } - val installedSorted = installed.filter { !it.hasUpdate && (showNsfwSources || !it.isNsfw) }.sortedWith(compareBy({ !it.isObsolete }, { it.name })) - val untrustedSorted = untrusted.sortedBy { it.name } + val updatesSorted = installed.filter { it.hasUpdate && (showNsfwSources || !it.isNsfw) } + .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.name })) + + val installedSorted = installed.filter { !it.hasUpdate && (showNsfwSources || !it.isNsfw) } + .sortedWith(compareBy { !it.isObsolete } + .thenBy(String.CASE_INSENSITIVE_ORDER) { it.name }) + + val untrustedSorted = untrusted.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.name })) + val availableSorted = available // Filter out already installed extensions and disabled languages .filter { avail -> @@ -74,7 +80,7 @@ open class ExtensionPresenter( avail.lang in activeLangs && (showNsfwSources || !avail.isNsfw) } - .sortedBy { it.name } + .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.name })) if (updatesSorted.isNotEmpty()) { val header = ExtensionGroupItem(context.getString(R.string.ext_updates_pending), updatesSorted.size, true)