Document that sorting is stable in each platform
#KT-12473 Fixed
This commit is contained in:
@@ -1234,6 +1234,8 @@ public actual fun CharArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the natural order of its elements.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*/
|
||||
public actual fun <T : Comparable<T>> Array<out T>.sort(): Unit {
|
||||
if (size > 1) sortArray(this)
|
||||
@@ -1241,6 +1243,8 @@ public actual fun <T : Comparable<T>> Array<out T>.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*/
|
||||
public fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int): Unit {
|
||||
if (size > 1) sortArrayWith(this, comparison)
|
||||
@@ -1304,6 +1308,8 @@ public inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int)
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit {
|
||||
if (size > 1) sortArrayWith(this, comparator)
|
||||
|
||||
Reference in New Issue
Block a user