import com.sun.deploy.util.StringUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class demo001 {
public static void main(String[] args) {
List list = new ArrayList<>();
list.add(new Student(1, "张三", 12));
list.add(new Student(2, "李四", 15));
list.add(new Student(3, "王五", 10));
//按照年龄升序排列过滤年龄为张三
//List collect = list.stream().filter(i->i.getName().equals("张三")).sorted(Comparator.comparing(Student::getAge)).collect(Collectors.toList());
List collect = list.stream().sorted(Comparator.comparing(Student::getAge)).collect(Collectors.toList());
//按照年龄降序排列
List collect1 = list.stream().sorted(Comparator.comparing(Student::getAge).reversed()).collect(Collectors.toList());
for (Student student : collect1) {
System.out.println(student.getAge()+" "+student.getName()+" "+student.getId());
}
}
}