reversed

fun <T> Comparator<T>.reversed(): Comparator<T>

Returns a comparator that imposes the reverse ordering of this comparator.

Samples

import samples.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val list = listOf("aa", "b", "bb", "a")

val lengthThenString = compareBy<String> { it.length }.thenBy { it }

val sorted = list.sortedWith(lengthThenString)
assertPrints(sorted, "[a, b, aa, bb]")

val sortedReversed = list.sortedWith(lengthThenString.reversed())
assertPrints(sortedReversed, "[bb, aa, b, a]") 
   //sampleEnd
}