目录
- sorted():自然排序,流中元素需实现Comparable接口
- sorted(Comparator com):Comparator排序器自定义排序
1. sorted()的示例演示
@Test
public void streamReduceThreeTest() throws Exception {
List<User> personList = new ArrayList<User>();
personList.add(new User("张三", 8900, 23, "男"));
personList.add(new User("李四", 7000, 25, "男"));
personList.add(new User("王二", 7800, 21, "女"));
personList.add(new User("齐大", 8200, 24, "女"));
personList.add(new User("晓丽", 7800, 24, "女"));
personList.add(new User("小华", 8200, 34, "男"));
personList.add(new User("小铭", 9500, 21, "女"));
personList.add(new User("小圣", 7900,