isSortedDescending
Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially using Comparable.compareTo, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(arrayOf<String>().isSortedDescending()) // true
println(arrayOf("cherry").isSortedDescending()) // true
val sorted = arrayOf("cherry", "banana", "apple")
println(sorted.isSortedDescending()) // true
val unsorted = arrayOf("banana", "cherry", "apple")
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(byteArrayOf().isSortedDescending()) // true
println(byteArrayOf(5).isSortedDescending()) // true
val sorted = byteArrayOf(5, 4, 3, 2, 1)
println(sorted.isSortedDescending()) // true
val unsorted = byteArrayOf(4, 5, 3, 2, 1)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(shortArrayOf().isSortedDescending()) // true
println(shortArrayOf(5).isSortedDescending()) // true
val sorted = shortArrayOf(5, 4, 3, 2, 1)
println(sorted.isSortedDescending()) // true
val unsorted = shortArrayOf(4, 5, 3, 2, 1)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(intArrayOf().isSortedDescending()) // true
println(intArrayOf(5).isSortedDescending()) // true
val sorted = intArrayOf(5, 4, 3, 2, 1)
println(sorted.isSortedDescending()) // true
val unsorted = intArrayOf(4, 5, 3, 2, 1)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(longArrayOf().isSortedDescending()) // true
println(longArrayOf(5L).isSortedDescending()) // true
val sorted = longArrayOf(5L, 4L, 3L, 2L, 1L)
println(sorted.isSortedDescending()) // true
val unsorted = longArrayOf(4L, 5L, 3L, 2L, 1L)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially using Float.compareTo, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
For floating-point arrays, NaN is considered greater than any other value (including positive infinity), and -0.0 is considered less than 0.0, consistent with Float.compareTo.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(floatArrayOf().isSortedDescending()) // true
println(floatArrayOf(3.14f).isSortedDescending()) // true
val sorted = floatArrayOf(3.14f, 2.5f, 1.0f)
println(sorted.isSortedDescending()) // true
val unsorted = floatArrayOf(2.5f, 3.14f, 1.0f)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially using Double.compareTo, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
For floating-point arrays, NaN is considered greater than any other value (including positive infinity), and -0.0 is considered less than 0.0, consistent with Double.compareTo.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(doubleArrayOf().isSortedDescending()) // true
println(doubleArrayOf(3.14).isSortedDescending()) // true
val sorted = doubleArrayOf(3.14, 2.5, 1.0)
println(sorted.isSortedDescending()) // true
val unsorted = doubleArrayOf(2.5, 3.14, 1.0)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(booleanArrayOf().isSortedDescending()) // true
println(booleanArrayOf(true).isSortedDescending()) // true
val sorted = booleanArrayOf(true, false, false)
println(sorted.isSortedDescending()) // true
val unsorted = booleanArrayOf(false, true, false)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(charArrayOf().isSortedDescending()) // true
println(charArrayOf('c').isSortedDescending()) // true
val sorted = charArrayOf('c', 'b', 'a')
println(sorted.isSortedDescending()) // true
val unsorted = charArrayOf('b', 'c', 'a')
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the collection is greater than or equal to the following element according to their natural sort order.
Returns true if the collection has fewer than two elements.
The elements are compared sequentially using Comparable.compareTo, and the collection 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 collection. The iteration order of some Iterable 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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(listOf<String>().isSortedDescending()) // true
println(listOf("cherry").isSortedDescending()) // true
val sorted = listOf("cherry", "banana", "apple")
println(sorted.isSortedDescending()) // true
val unsorted = listOf("banana", "cherry", "apple")
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(uintArrayOf().isSortedDescending()) // true
println(uintArrayOf(5u).isSortedDescending()) // true
val sorted = uintArrayOf(5u, 4u, 3u, 2u, 1u)
println(sorted.isSortedDescending()) // true
val unsorted = uintArrayOf(4u, 5u, 3u, 2u, 1u)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ulongArrayOf().isSortedDescending()) // true
println(ulongArrayOf(5uL).isSortedDescending()) // true
val sorted = ulongArrayOf(5uL, 4uL, 3uL, 2uL, 1uL)
println(sorted.isSortedDescending()) // true
val unsorted = ulongArrayOf(4uL, 5uL, 3uL, 2uL, 1uL)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ubyteArrayOf().isSortedDescending()) // true
println(ubyteArrayOf(5u).isSortedDescending()) // true
val sorted = ubyteArrayOf(5u, 4u, 3u, 2u, 1u)
println(sorted.isSortedDescending()) // true
val unsorted = ubyteArrayOf(4u, 5u, 3u, 2u, 1u)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}Returns true if each element in the array is greater than or equal to the following element according to their natural sort order.
Returns true if the array has fewer than two elements.
The elements are compared sequentially, and the array is considered sorted in descending order if for each pair of adjacent elements the preceding element is not less than the following one.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ushortArrayOf().isSortedDescending()) // true
println(ushortArrayOf(5u).isSortedDescending()) // true
val sorted = ushortArrayOf(5u, 4u, 3u, 2u, 1u)
println(sorted.isSortedDescending()) // true
val unsorted = ushortArrayOf(4u, 5u, 3u, 2u, 1u)
println(unsorted.isSortedDescending()) // false
//sampleEnd
}