W3cubDocs

/Kotlin

compareByDescending

inline fun <T> compareByDescending(
    crossinline selector: (T) -> Comparable<*>?
): Comparator<T>

Creates a descending comparator using the function to transform value to a Comparable instance for comparison.

inline fun <T, K> compareByDescending(
    comparator: Comparator<in K>, 
    crossinline selector: (T) -> K
): Comparator<T>

Platform and version requirements: JVM

inline fun <T, K> compareByDescending(
    comparator: Comparator<in K>, 
    crossinline selector: (T) -> K
): Comparator<T>

Platform and version requirements: JS

Creates a descending comparator using the selector function to transform values being compared and then applying the specified comparator to compare transformed values.

Note that an order of comparator is reversed by this wrapper.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.comparisons/compare-by-descending.html