sortedArrayWith
Returns an array with all elements of this array sorted according the specified comparator.
fun <T> Array<out T>.sortedArrayWith(comparator: Comparator<in T>): Array<out T>(source)
val words = arrayOf("banana", "apple", "cherry")
val sorted = words.sortedArrayWith(
Comparator { a, b -> a.length.compareTo(b.length) }
)
println(sorted.joinToString())