n

    nkiesel

    2 years ago
    Should there be standard support to sort lists of Strings locale-dependant? Something like
    fun Iterable<String>.sortedWith(collator: Collator) = this.map { collator.getCollationKey(it) }.sorted().map { it.sourceString }
    ilya.gorbunov

    ilya.gorbunov

    2 years ago
    Since
    Collator
    implements
    Comparator
    , why not just standard
    list.sortWith(collator)
    ? Is it an optimization for large lists?
    n

    nkiesel

    2 years ago
    Yes, collator documentation says that for sorting lists where items must be compared multiple times, converting to CollationKey is more efficient. Caveat: I did not measure what the break-even point for this is.