Collections.sort without comparator now uses natural order.
#KT-9771 Fixed
This commit is contained in:
@@ -6,8 +6,10 @@ import java.util.*
|
||||
public object Collections {
|
||||
public fun max<T>(col: Collection<T>, comp: Comparator<in T>): T = java.util.max(col, comp)
|
||||
|
||||
public fun <T> sort(list: MutableList<T>): Unit = java.util.sort(list)
|
||||
@Deprecated("Use list.sort() instead.", ReplaceWith("list.sort()"))
|
||||
public fun <T: Comparable<T>> sort(list: MutableList<T>): Unit = java.util.sort(list, naturalOrder())
|
||||
|
||||
@Deprecated("Use list.sortWith(comparator) instead.", ReplaceWith("list.sortWith(comparator)"))
|
||||
public fun <T> sort(list: MutableList<T>, comparator: java.util.Comparator<in T>): Unit = java.util.sort(list, comparator)
|
||||
|
||||
@Deprecated("Use list.reverse() instead.", ReplaceWith("list.reverse()"))
|
||||
@@ -23,10 +25,7 @@ public object Collections {
|
||||
}
|
||||
|
||||
@library("collectionsMax")
|
||||
internal fun max<T>(col: Collection<T>, comp: Comparator<in T>): T = noImpl
|
||||
private fun max<T>(col: Collection<T>, comp: Comparator<in T>): T = noImpl
|
||||
|
||||
@library("collectionsSort")
|
||||
internal fun <T> sort(list: MutableList<T>): Unit = noImpl
|
||||
|
||||
@library("collectionsSort")
|
||||
internal fun <T> sort(list: MutableList<T>, comparator: java.util.Comparator<in T>): Unit = noImpl
|
||||
private fun <T> sort(list: MutableList<T>, comparator: Comparator<in T>): Unit = noImpl
|
||||
|
||||
@@ -564,8 +564,9 @@ class CollectionTest {
|
||||
}
|
||||
|
||||
@test fun sorted() {
|
||||
assertEquals(listOf(1, 3, 7), listOf(3, 7, 1).sorted())
|
||||
assertEquals(listOf(7, 3, 1), listOf(3, 7, 1).sortedDescending())
|
||||
val data = listOf(11, 3, 7)
|
||||
assertEquals(listOf(3, 7, 11), data.sorted())
|
||||
assertEquals(listOf(11, 7, 3), data.sortedDescending())
|
||||
}
|
||||
|
||||
@test fun sortedBy() {
|
||||
|
||||
Reference in New Issue
Block a user