thenDescending所在位置是kotlin.comparisons.thenDescending,其相关用法介绍如下。

用法:

infix fun <T> Comparator<T>.thenDescending(
    comparator: Comparator<in T>
): Comparator<T>

将此比较器与给定的comparator 结合起来,以便仅当前者认为值相等时才应用后者。

例子:

import kotlin.test.*

fun main(args: Array<String>) {
//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)

println(sorted) // [b, A, a, bb, aa]
//sampleEnd
}

输出:

[b, A, a, bb, aa]