见到的List排序
public void testSort(){
List<Integer> list = new ArrayList<Integer>();
Random random = new Random();
for(int i = 0; i < 100; i++)
list.add(random.nextInt(10000));
System.out.println(list);
Collections.sort(list, new Comparator<Integer>(){
@Override
public int compare(Integer o1, Integer o2) {
//return o1.intValue() - o2.intValue();// ASC 正序,由小到大
return o2.intValue() - o1.intValue(); // DESC 逆序,由大到小
}});
System.out.println(list);
}