isSortedDescending
Returns true if each element in the sequence is greater than or equal to the following element according to their natural sort order.
Returns true if the sequence has fewer than two elements.
The elements are compared sequentially using Comparable.compareTo, and the sequence is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Note that the result depends on the iteration order of the sequence. The iteration order of some Sequence implementations may be unstable (change from one invocation to the next), in which case this function may return inconsistent results.
For elements of floating-point types (Double, Float), NaN is considered greater than any other value (including positive infinity), and -0.0 is considered less than 0.0, consistent with Double.compareTo and Float.compareTo.
The operation is terminal.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(sequenceOf<String>().isSortedDescending()) // true
println(sequenceOf("cherry").isSortedDescending()) // true
val sorted = sequenceOf("cherry", "banana", "apple")
println(sorted.isSortedDescending()) // true
val unsorted = sequenceOf("banana", "cherry", "apple")
println(unsorted.isSortedDescending()) // false
//sampleEnd
}