Cleanup ordering, improve API
This commit is contained in:
@@ -114,7 +114,7 @@ class KDocConfig() {
|
||||
|
||||
private object LongestFirstStringComparator : Comparator<String> {
|
||||
override fun compare(o1: String, o2: String): Int {
|
||||
return compareBy<String>(o1, o2, { length() }, { this })
|
||||
return compareValuesBy<String>(o1, o2, { it.length() }, { it })
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user