排序算法
package cn.gls.jdk18;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
public class SortTest {
public static void main(String[] args) {
List<String> list = new LinkedList<>();
list.add("zhangsan");
list.add("lisi");
list.add("wangwu");
list.add("zhaoliu");
//正序
Collections.sort(list);
System.out.println(list);
//倒序
list.sort(Comparator.reverseOrder());
System.out.println(list);
//随机混排
Collections.shuffle(list);
System.out.println(list);
}
}