elect
04/15/2026, 7:39 AMval languagePresent by lazy {
// Create a mutable list to hold the sorted languages
buildList {
// Define the order of languages based on specific settings properties
// The firstLanguageOrder list contains the settings properties for the languages that should be prioritized in the sorting order.
val firstLanguageOrder = listOf(
SettingsProperty.LANGUAGE_PRESENT_ENGLISH_UK,
SettingsProperty.LANGUAGE_PRESENT_GERMAN,
SettingsProperty.LANGUAGE_PRESENT_SPANISH,
SettingsProperty.LANGUAGE_PRESENT_FRENCH,
SettingsProperty.LANGUAGE_PRESENT_ITALIAN
)
for (property in firstLanguageOrder)
settingsCarManager.languagePresent().filterTo(this) { it == languages[property] }
val remainingLanguages = settingsCarManager.languagePresent().filter { it !in this }
val (latin, nonLatin) = remainingLanguages.partition { it.iso8859 == LanguageSettingsItem.LATIN }
// The remaining languages are sorted alphabetically, with Latin-based languages appearing before non-Latin languages.
latin.sortedBy { it.name }.toCollection(this)
// Non-Latin languages are added to the end of the list, sorted alphabetically by their name.
nonLatin.sortedBy { it.name }.toCollection(this)
}
is there a more idiomatic way?andries.fc
04/20/2026, 3:32 PM