Replace deprecated reverse method usages.

This commit is contained in:
Ilya Gorbunov
2015-08-26 19:59:25 +03:00
parent ca798d8d71
commit 84d3d42e05
4 changed files with 10 additions and 10 deletions
+7 -7
View File
@@ -548,49 +548,49 @@ public fun <T : Comparable<T>> Array<out T>.sortedDescending(): List<T> {
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun ByteArray.sortedDescending(): List<Byte> { public fun ByteArray.sortedDescending(): List<Byte> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun CharArray.sortedDescending(): List<Char> { public fun CharArray.sortedDescending(): List<Char> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun DoubleArray.sortedDescending(): List<Double> { public fun DoubleArray.sortedDescending(): List<Double> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun FloatArray.sortedDescending(): List<Float> { public fun FloatArray.sortedDescending(): List<Float> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun IntArray.sortedDescending(): List<Int> { public fun IntArray.sortedDescending(): List<Int> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun LongArray.sortedDescending(): List<Long> { public fun LongArray.sortedDescending(): List<Long> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
* Returns a list of all elements sorted descending according to their natural sort order. * Returns a list of all elements sorted descending according to their natural sort order.
*/ */
public fun ShortArray.sortedDescending(): List<Short> { public fun ShortArray.sortedDescending(): List<Short> {
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
} }
/** /**
@@ -589,7 +589,7 @@ class CollectionTest {
} }
test fun sortedWith() { test fun sortedWith() {
val comparator = compareBy<String> { it.toUpperCase().reverse() } val comparator = compareBy<String> { it.toUpperCase().reversed() }
val data = listOf("cat", "dad", "BAD") val data = listOf("cat", "dad", "BAD")
expect(listOf("BAD", "dad", "cat")) { data.sortedWith(comparator) } expect(listOf("BAD", "dad", "cat")) { data.sortedWith(comparator) }
@@ -333,7 +333,7 @@ public class SequenceTest {
} }
test fun sortedWith() { test fun sortedWith() {
val comparator = compareBy { s: String -> s.reverse() } val comparator = compareBy { s: String -> s.reversed() }
assertEquals(listOf("act", "wast", "test"), sequenceOf("act", "test", "wast").sortedWith(comparator).toList()) assertEquals(listOf("act", "wast", "test"), sequenceOf("act", "test", "wast").sortedWith(comparator).toList())
} }
@@ -105,7 +105,7 @@ fun ordering(): List<GenericFunction> {
} }
body(ArraysOfPrimitives) { body(ArraysOfPrimitives) {
""" """
return copyOf().apply { sort() }.reverse() return copyOf().apply { sort() }.reversed()
""" """
} }