sortedWith

Common
JVM
JS
Native
1.0
fun <T> Array<out T>.sortedWith(
    comparator: Comparator<in T>
): List<T>
fun <T> Iterable<T>.sortedWith(
    comparator: Comparator<in T>
): List<T>

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.

Common
JVM
JS
Native
1.0
fun ByteArray.sortedWith(
    comparator: Comparator<in Byte>
): List<Byte>
fun ShortArray.sortedWith(
    comparator: Comparator<in Short>
): List<Short>
fun IntArray.sortedWith(
    comparator: Comparator<in Int>
): List<Int>
fun LongArray.sortedWith(
    comparator: Comparator<in Long>
): List<Long>
fun FloatArray.sortedWith(
    comparator: Comparator<in Float>
): List<Float>
fun DoubleArray.sortedWith(
    comparator: Comparator<in Double>
): List<Double>
fun BooleanArray.sortedWith(
    comparator: Comparator<in Boolean>
): List<Boolean>
fun CharArray.sortedWith(
    comparator: Comparator<in Char>
): List<Char>

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