then Descending
infix fun <T> Comparator<T>.thenDescending(comparator: Comparator<in T>): Comparator<T>
Content copied to clipboard
Combines this comparator and the given comparator such that the latter is applied only when the former considered values equal.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf("A", "aa", "b", "bb", "a")
val lengthThenCaseInsensitive = compareBy<String> { it.length }
.thenDescending(String.CASE_INSENSITIVE_ORDER)
val sorted = list.sortedWith(lengthThenCaseInsensitive)
assertPrints(sorted, "[b, A, a, bb, aa]")
//sampleEnd
}