排序算法

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);


}


}
posted on 2019-08-10 12:11  guols  阅读(187)  评论(0编辑  收藏  举报