JAVA lambda多条件排序
有时候需要代码中内存排序
以下是两个例子:
eg1.list实体类
以下是两个例子:
eg1.list实体类
list = list.stream()
.sorted(Comparator.comparingDouble(aaEntity::getbbb).thenComparing(aaEntity::getccc).reversed())
.collect(Collectors.toList());
eg2:list map
list = list.stream().sorted(
Comparator.comparing((Map<String, Object> i) -> i.get("bbb").toString()).reversed()
.thenComparing((Map<String, Object> i) -> i.get("ccc").toString())
)
.collect(Collectors.toList());