W3cubDocs

/Kotlin

sortWith

Platform and version requirements: JS (1.0), Native (1.0)
fun <T> Array<out T>.sortWith(comparator: Comparator<in T>)

Sorts the array in-place according to the order specified by the given comparator.

The sort is stable. It means that equal elements preserve their order relative to each other after sorting.

Platform and version requirements: JS (1.0), Native (1.0)
fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>)

Sorts elements in the list in-place according to the order specified with comparator.

The sort is stable. It means that equal elements preserve their order relative to each other after sorting.

Platform and version requirements: JVM (1.0)
fun <T> Array<out T>.sortWith(comparator: Comparator<in T>)

Sorts the array in-place according to the order specified by the given comparator.

The sort is stable. It means that equal elements preserve their order relative to each other after sorting.

Platform and version requirements: JVM (1.0)
fun <T> Array<out T>.sortWith(
    comparator: Comparator<in T>, 
    fromIndex: Int = 0, 
    toIndex: Int = size)
Platform and version requirements: Native (1.3)
fun <T> Array<out T>.sortWith(
    comparator: Comparator<in T>, 
    fromIndex: Int = 0, 
    toIndex: Int = size)

Sorts a range in the array in-place with the given comparator.

The sort is stable. It means that equal elements preserve their order relative to each other after sorting.

Platform and version requirements: JVM (1.0)
fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>)

Sorts elements in the list in-place according to the order specified with comparator.

The sort is stable. It means that equal elements preserve their order relative to each other after sorting.

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sort-with.html