sorted

Common
JVM
JS
Native
1.0
fun <T : Comparable<T>> Array<out T>.sorted(): List<T>
(source)
fun <T : Comparable<T>> Iterable<T>.sorted(): List<T>
(source)

Returns a list of all elements sorted according to their natural sort order.

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.sorted(): List<Byte>
(source)
fun ShortArray.sorted(): List<Short>
(source)
fun IntArray.sorted(): List<Int>
(source)
fun LongArray.sorted(): List<Long>
(source)
fun FloatArray.sorted(): List<Float>
(source)
fun DoubleArray.sorted(): List<Double>
(source)
fun CharArray.sorted(): List<Char>
(source)
@ExperimentalUnsignedTypes fun UIntArray.sorted(): List<UInt>
(source)
@ExperimentalUnsignedTypes fun ULongArray.sorted(): List<ULong>
(source)
@ExperimentalUnsignedTypes fun UByteArray.sorted(): List<UByte>
(source)
@ExperimentalUnsignedTypes fun UShortArray.sorted(): List<UShort>
(source)

Returns a list of all elements sorted according to their natural sort order.