Should there be standard support to sort lists of ...
# stdlib
n
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 }
i
Since
Collator
implements
Comparator
, why not just standard
list.sortWith(collator)
? Is it an optimization for large lists?
n
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.