对一个字段排序
使用Stream流进行排序
xxList = xxList.stream().sorted(Comparator.comparing(Xx::getId)).collect(Collectors.toList());
xxList = xxList.stream().sorted(Comparator.comparing(Xx::getId, Comparator.reverseOrder())).collect(Collectors.toList());
使用Hutool工具类的方法进行排序
CollUtil.reverse(CollUtil.sortByProperty(xxList, "id"));
对多个字段依次排序
使用Stream流进行排序
xxList = xxList.stream().sorted(Comparator.comparing(Xx::getId, Comparator.reverseOrder()).thenComparing(Xx::getRemark, Comparator.reverseOrder())).collect(Collectors.toList());