Java8根据list中某个字段排序
排序
List<User> list = new ArrayList<>(tempList);//tempList中有user对象
list.stream().sorted(Comparator.comparing(User::getSort)).collect(Collectors.toList());
return list;
//需要逆序
list.stream().sorted(Comparator.comparing(User::getSort).reversed()).collect(Collectors.toList());