我有一个 HashMap
,它的键是 String
中的 Date
,值是自定义的 ArrayList
对象。我想根据键对这个 hashmap 进行排序。我该怎么做?
HashMap<String,List<ClassName>> hashmap = new HashMap<String,List<ClassName>>();
当Hashmap
是这样的时候:
{"2015/07/15 : List("Object1","object2","object3")
"2015/07/14 :List("Object4" , "Object5")}
请提出建议。
最佳答案
您可以使用 TreeMap
代替 HashMap
。 TreeMap
实现了 Sorted Map 接口(interface)。
关于java - 在java中对集合进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32753323/