Cleanup ordering, improve API

This commit is contained in:
Ilya Ryzhenkov
2014-11-07 17:07:35 +03:00
parent e890c2ee0d
commit 828ba385ea
13 changed files with 208 additions and 194 deletions
@@ -80,8 +80,7 @@ fun ordering(): List<GenericFunction> {
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> y.compareTo(x) }
java.util.Collections.sort(sortedList, sortBy)
java.util.Collections.sort(sortedList, comparator { x, y -> y.compareTo(x) })
return sortedList
"""
}
@@ -105,7 +104,7 @@ fun ordering(): List<GenericFunction> {
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
"""
@@ -128,7 +127,7 @@ fun ordering(): List<GenericFunction> {
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
"""
@@ -150,7 +149,7 @@ fun ordering(): List<GenericFunction> {
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(y).compareTo(order(x)) }
val sortBy: Comparator<T> = compareByDescending(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
"""