import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.Comparator.comparingLong;
import static java.util.stream.Collectors.*;
/**
* @Author:
* @www.1b23.com
* @Description:
*/
public class test {
public static void main(String[] args) {
List list = new ArrayList<>();
list.add(new User(21L, "张三"));
list.add(new User(25L, "李四"));
list.add(new User(22L, "王五"));
list.add(new User(19L, "赵柳"));
list.add(new User(32L, "王5"));
list.add(new User(29L, "王6"));
list.add(new User(21L, "王7"));
// 对象根据年龄属性升序排序
List newList = list.stream().sorted(Comparator.comparing(User::getAge)).collect(toLis