Reverse range and sortDescending range #KT-36955
This commit is contained in:
@@ -2278,6 +2278,89 @@ public fun <T> Array<out T>.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArrayOfComparable
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun <T : Comparable<T>> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
@@ -2289,69 +2372,6 @@ public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
|
||||
*/
|
||||
public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the order specified by the given [comparator].
|
||||
*
|
||||
@@ -2366,7 +2386,8 @@ public actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*/
|
||||
public fun <T> Array<out T>.sortWith(comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex, comparator)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user