1.排序
val hashMap = HashMap<String, String>()
val map = hashMap.toSortedMap(Comparator { o1, o2 -> o1.compareTo(o2) })
2.遍历
for (entry in map.entries) {
val key = entry.key
val value = entry.value
}
val hashMap = HashMap<String, String>()
val map = hashMap.toSortedMap(Comparator { o1, o2 -> o1.compareTo(o2) })
for (entry in map.entries) {
val key = entry.key
val value = entry.value
}
本文标题:2019-06-25 Map排序+遍历
本文链接:https://www.haomeiwen.com/subject/tflxcctx.html
网友评论