2019-02-13 JAVA 8 LAMBDA 给对象排序

正序

collection.stream().sorted(Comparator.comparing(MyClass::getProp));

倒序 desc

collection.stream().sorted(Comparator.comparing(MyClass::getProp)).reversed();

https://www.baeldung.com/java-8-comparator-comparing

你可能感兴趣的:(2019-02-13 JAVA 8 LAMBDA 给对象排序)