[英]How to sort generic list in java8
我有一个地图Map<K, List<V>> inputMap
我想在存储到列表之前对列表进行排序
List<String> outputList = inputMap.keySet()
.stream()
.filter(Objects::nonNull)
.map(key -> (key + "==" + inputMap.get(key).sort(c);))
.sorted()
.collect(Collectors.toList());
这个怎么样?
List<String> outputList = inputMap.keySet().stream()
.filter(Objects::nonNull)
.map(key -> key + "=="
+ inputMap.get(key).stream().sorted(c)
.collect(Collectors.toList()))
.sorted()
.collect(Collectors.toList());
要么
List<String> outputList = inputMap.keySet().stream()
.filter(Objects::nonNull)
.map(key -> key + "=="
+ inputMap.get(key).stream().sorted(c)
.map(Object::toString)
.collect(Collectors.joining(", ","[","]")))
.sorted()
.collect(Collectors.toList());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.