List排序
//按照某个字段进行正序排序
list.sort((x,y) ->Integer.compare(Integer.valueOf(x.getCourseDuration()),Integer.valueOf(y.getCourseDuration())));
//按照某个字段进行倒序排序
list.sort((x,y) ->Integer.compare(Integer.valueOf(y.getCourseDuration()),Integer.valueOf(x.getCourseDuration())));
//按照时间正序排序
studentList.stream().sorted(Comparator.comparing(Student::getCreateTime)).collect(Collectors.toList());
//按照时间倒序排序
studentList.stream().sorted(Comparator.comparing(Student::getCreateTime).reversed()).collect(Collectors.toList());
标签:倒序,valueOf,List,getCourseDuration,Integer,排序
From: https://www.cnblogs.com/striver20/p/17507848.html