标签:lis tom sort eve com slist sorted tag list
List<Person> list = Arrays.asList(
new Person(22, "shaomch", "man"),
new Person(26, "mike", "wemon"),
new Person(24, "tom", "wemon"),
new Person(22, "tom", "wemon")
);
//升序排列
List<Person> list1 = list.stream().sorted(Comparator.comparing(Person::getAge)).collect(Collectors.toList());
//降序排列
List<Person> list2 = list.stream().sorted(Comparator.comparing(Person::getAge).reversed()).collect(Collectors.toList());
标签:lis tom sort eve com slist sorted tag list
原文地址:http://www.cnblogs.com/michaelShao/p/6690231.html