W3cubDocs

/Kotlin

sort

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun IntArray.sort()
fun LongArray.sort()
fun ByteArray.sort()
fun ShortArray.sort()
fun DoubleArray.sort()
fun FloatArray.sort()
fun CharArray.sort()

Sorts the array in-place.

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

Sorts the array in-place according to the natural order of its elements.

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

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun UIntArray.sort()
@ExperimentalUnsignedTypes fun ULongArray.sort()
@ExperimentalUnsignedTypes fun UByteArray.sort()
@ExperimentalUnsignedTypes fun UShortArray.sort()

Sorts the array in-place.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T : Comparable<T>> MutableList<T>.sort()

Sorts elements in the list in-place 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)
fun <T> Array<out T>.sort(
    fromIndex: Int = 0, 
    toIndex: Int = size)

Sorts a range in the array in-place.

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)
fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size)
fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size)
fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size)
fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size)
fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size)
fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size)
fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size)

Sorts a range in the array in-place.

Platform and version requirements: JVM (1.0)
fun <T> MutableList<T>.sort(comparator: Comparator<in T>)
Deprecated: Use sortWith(comparator) instead.
inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int)
Deprecated: Use sortWith(Comparator(comparison)) instead.
Platform and version requirements: JS (1.1)
fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int)

Sorts the array in-place according to the order specified by the given comparison function.

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

Platform and version requirements: JS (1.1)
inline fun ByteArray.sort(
    noinline comparison: (a: Byte, b: Byte) -> Int)
inline fun ShortArray.sort(
    noinline comparison: (a: Short, b: Short) -> Int)
inline fun IntArray.sort(
    noinline comparison: (a: Int, b: Int) -> Int)
inline fun LongArray.sort(
    noinline comparison: (a: Long, b: Long) -> Int)
inline fun FloatArray.sort(
    noinline comparison: (a: Float, b: Float) -> Int)
inline fun DoubleArray.sort(
    noinline comparison: (a: Double, b: Double) -> Int)
inline fun CharArray.sort(
    noinline comparison: (a: Char, b: Char) -> Int)

Sorts the array in-place according to the order specified by the given comparison function.

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