1、排序
List<Person> personList = new ArrayList<>();
personList.add(new Person("test1",1,"2019-09-11 7:48:58"));
personList.add(new Person("test2",1,"2019-09-15 8:48:58"));
personList.add(new Person("test3",1,"2019-09-13 9:48:58"));
personList.add(new Person("test4",1,"2019-09-12 12:48:58"));
personList.add(new Person("test5",1,"2019-09-16 10:48:58"));
personList = personList.stream().sorted(Comparator.comparing(Person::getSort).thenComparing(Comparator.comparing(Person::getDate)).reversed()).collect(Collectors.toList());
System.out.println("personList"+personList);
2、集合转map
List<Person> list = new ArrayList();
list.add(new Person("A",1));
list.add(new Person("B",2));
Map<String,Person> map = list.stream().collect(Collectors.toMap(Person::getName, a -> a, (k1, k2) -> k1));
System.out.println("map="+map);