// 1.排序,带参数类型
list.sort((String s1, String s2) -> s1.compareTo(s2));
list.sort(( LibraryDO lib1, LibraryDO lib2) -> lib2.getId().compareTo(lib2.getId()));
// 使用默认方法排序
Collections.sort(list, Comparator.comparing(LibraryDO::getId)); //升序
Collections.reverse(list); // 倒序排列
//随机打乱顺序
Collections.shuffle(list);
//更多排序
//默认ASC排序)
List<LibraryDO> collect = users.stream().sorted(Comparator.comparing(LibraryDO::getId)).collect(Collectors.toList());
//DESC排序)
List<LibraryDO> collect = users.stream().sorted(Comparator.comparing(LibraryDO::getId).reversed()).collect(Collectors.toList());

// 2.数组去重
List<String> collect = list.stream().distinct().collect(Collectors.toList());
// 数组去重转换为字符串
String joining = list.stream().distinct().collect(Collectors.joining(","));
// 根据对象属性去重
List<LibraryDO> lib = list.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(LibraryDO::getId))), ArrayList<LibraryDO>::new));

// 4.获取对象某一属性返回list
List<String> collect= list.stream().map(LibraryDO::getId).collect(Collectors.toList());
// 获取对象某一属性返回数组
Integer[] array = list.stream().map(LibraryDO::getId).collect(Collectors.toList()).stream().toArray(Integer[]::new);
// 获取对象某一属性返回数组过滤非空
Integer[] array = list.stream().map(LibraryDO::getId).filter(x -> x !=null).collect(Collectors.toList()).stream().toArray(Integer[]::new);
//5.修改对象属性值
List<LibraryDO> lib = list.stream().map(p -> {p.setId(p.getId() + 1);return p;}).collect(Collectors.toList())
/**
* LibraryDO 对象
*/
public class LibraryDO implements Serializable {
//ID
private Integer id;
//图书馆名称
private String libName;
//网址
private String libUrl;
}

排序