假设我喜欢:
Map<String, List<MyState>> map = new HashMap<>();
map.computeIfAbsent(key, file -> new ArrayList<>()).add(myState);
map.put("aa",list1..)
map.put("bb",list2..)
map.put("cc",list3..)
public class MyState {
private String state;
private String date;
}
Run Code Online (Sandbox Code Playgroud)
我要地图值进行排序List<MyState>
的MyState::date
,然后通过 MyState::state
您可以这样做:
Comparator<MyState> comparator = Comparator.comparing(MyState::getDate)
.thenComparing(MyState::getState);
map.values()
.forEach(l -> l.sort(comparator));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
378 次 |
最近记录: |