list从小到大,排序----这么简单
public class LambdaTest { public static void main(String[] args) { List list = Arrays.asList(5,2,3,1,9); int N = list.size(); int t = 0; Collections.sort(list); System.out.println("顺序--"+list); Collections.reverse(list); System.out.println("倒叙--"+list); Collections.shuffle(list); System.out.println("随机--"+list); } }
顺序--[1, 2, 3, 5, 9]
倒叙--[9, 5, 3, 2, 1]
随机--[9, 1, 5, 2, 3]