sortedWith

fun <T> Array<out T>.sortedWith(comparator: Comparator<in T>): List<T>(source)
fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T>(source)

Returns a list of all elements sorted according to the specified comparator.

The sort is stable. It means that equal elements preserve their order relative to each other after sorting.

Since Kotlin

1.0

fun IntArray.sortedWith(comparator: Comparator<in Int>): List<Int>(source)

Returns a list of all elements sorted according to the specified comparator.

Since Kotlin

1.0