Create SortedMap with Comparator and items

KT-34142
This commit is contained in:
Valeriy.Vyrva
2019-10-02 17:52:05 +03:00
committed by Ilya Gorbunov
parent e3fb74b656
commit c023a02884
4 changed files with 29 additions and 0 deletions
@@ -43,6 +43,13 @@ class Maps {
assertPrints(map.values, "[2, 3, 1]")
}
@Sample
fun sortedMapWithComparatorFromPairs() {
val map = sortedMapOf(compareBy<String> { it.length }.thenBy { it }, Pair("abc", 1), Pair("c", 3), Pair("bd", 4), Pair("bc", 2))
assertPrints(map.keys, "[c, bc, bd, abc]")
assertPrints(map.values, "[3, 2, 4, 1]")
}
@Sample
fun emptyReadOnlyMap() {
val map = emptyMap<String, Int>()