Document that sorting is stable in each platform
#KT-12473 Fixed
This commit is contained in:
@@ -1198,6 +1198,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)
|
||||
@@ -1205,6 +1207,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)
|
||||
@@ -1268,6 +1272,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -93,6 +93,8 @@ public actual fun <T> Iterable<T>.shuffled(): List<T> = toMutableList().apply {
|
||||
|
||||
/**
|
||||
* Sorts elements in the list in-place according to their natural sort order.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*/
|
||||
public actual fun <T : Comparable<T>> MutableList<T>.sort(): Unit {
|
||||
collectionsSort(this, naturalOrder())
|
||||
@@ -100,6 +102,8 @@ public actual fun <T : Comparable<T>> MutableList<T>.sort(): Unit {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public actual fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
|
||||
collectionsSort(this, comparator)
|
||||
|
||||
Reference in New Issue
Block a user