W3cubDocs

/Kotlin

sorted

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T : Comparable<T>> Array<out T>.sorted(): List<T>
fun <T : Comparable<T>> Iterable<T>.sorted(): List<T>

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.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun ByteArray.sorted(): List<Byte>
fun ShortArray.sorted(): List<Short>
fun IntArray.sorted(): List<Int>
fun LongArray.sorted(): List<Long>
fun FloatArray.sorted(): List<Float>
fun DoubleArray.sorted(): List<Double>
fun CharArray.sorted(): List<Char>
@ExperimentalUnsignedTypes fun UIntArray.sorted(): List<UInt>
@ExperimentalUnsignedTypes fun ULongArray.sorted(): List<ULong>
@ExperimentalUnsignedTypes fun UByteArray.sorted(): List<UByte>
@ExperimentalUnsignedTypes fun UShortArray.sorted(): List<UShort>

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

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sorted.html