W3cubDocs

/Kotlin

sortedWith

Platform and version requirements: JVM (1.0), JS (1.0), 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.

Platform and version requirements: JVM (1.0), JS (1.0), 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.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sorted-with.html