W3cubDocs

/Kotlin

sortedByDescending

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <T, R : Comparable<R>> Array<out T>.sortedByDescending(
    crossinline selector: (T) -> R?
): List<T>
inline fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(
    crossinline selector: (T) -> R?
): List<T>

Returns a list of all elements sorted descending according to natural sort order of the value returned by specified selector function.

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)
inline fun <R : Comparable<R>> ByteArray.sortedByDescending(
    crossinline selector: (Byte) -> R?
): List<Byte>
inline fun <R : Comparable<R>> ShortArray.sortedByDescending(
    crossinline selector: (Short) -> R?
): List<Short>
inline fun <R : Comparable<R>> IntArray.sortedByDescending(
    crossinline selector: (Int) -> R?
): List<Int>
inline fun <R : Comparable<R>> LongArray.sortedByDescending(
    crossinline selector: (Long) -> R?
): List<Long>
inline fun <R : Comparable<R>> FloatArray.sortedByDescending(
    crossinline selector: (Float) -> R?
): List<Float>
inline fun <R : Comparable<R>> DoubleArray.sortedByDescending(
    crossinline selector: (Double) -> R?
): List<Double>
inline fun <R : Comparable<R>> BooleanArray.sortedByDescending(
    crossinline selector: (Boolean) -> R?
): List<Boolean>
inline fun <R : Comparable<R>> CharArray.sortedByDescending(
    crossinline selector: (Char) -> R?
): List<Char>

Returns a list of all elements sorted descending according to natural sort order of the value returned by specified selector function.

© 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-by-descending.html