根据list集合某个字段进行集合排序

假设有学生类Student,学生集合studentList,根据年龄age排序(这里是升序)

studentList.sort((x, y) -> Double.compare(x.getAge(), y.getAge()));//这方法需要jdk1.8以上

猜你喜欢

转载自blog.csdn.net/weixin_46099269/article/details/114695147