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
@@ -23,11 +23,7 @@ class MapJVMTest {
test fun toSortedMapWithComparator() {
val map = mapOf(Pair("c", 3), Pair("bc", 2), Pair("bd", 4), Pair("abc", 1))
val c = comparator<String>{ a, b ->
val answer = a.length() - b.length()
if (answer == 0) a.compareTo(b) else answer
}
val sorted = map.toSortedMap(c)
val sorted = map.toSortedMap(compareBy<String> { it.length() } thenBy { it })
assertEquals(arrayListOf("c", "bc", "bd", "abc"), sorted.keySet().toList())
assertEquals(1, sorted["abc"])
assertEquals(2, sorted["bc"])