From daf5d94d5af6d562585663d63554b96914995740 Mon Sep 17 00:00:00 2001 From: firelight <147925818+fire-light42@users.noreply.github.com> Date: Tue, 7 Jul 2026 12:27:35 +0000 Subject: [PATCH] Fix: Subtitle ordering on names --- .../com/lagradost/cloudstream3/utils/AppContextUtils.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt index 65519c0f1..c0be85a3f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt @@ -365,8 +365,14 @@ object AppContextUtils { } } + /** Sort subtitles by names */ fun sortSubs(subs: Set): List { - return subs.sortedBy { it.name } + // Be aware, sorting by "$originalName $nameSuffix" causes "a (b) 1" < "a 1", + // where "originalName then nameSuffix" preserves "a 1" < "a (b) 1", because we do not compare '(' and '1'. + return subs + .sortedWith( + compareBy { subtitle: SubtitleData -> subtitle.originalName } + .thenBy { subtitle: SubtitleData -> subtitle.nameSuffix }) } fun Context.getApiSettings(): HashSet {