import java.util.*;
/**
* @ClassName CollectionTest
* @Description To
* @Author BlazeJack
* @Date 2019/9/10 10:51
* @Version 1.0
**/
class MyIntCom implements Comparator{
public int compare(Object o1, Object o2) {
Integer a = (Integer) o1;
Integer b = (Integer) o2;
//小于返回-1,个人认为是前面减去后面
if(a<= b){
return -1;
}
return 1;
}
}
public class CollectionTest {
public static String check(List <Integer>list){
int len = list.size();
for(int i = 1; i < len; i++){
Integer a = list.get(i-1);
Integer b = list.get(i);
if( a> b){
return "false";
}
}
return "true";
}
public static void main(String[] args) {
{
List<Integer> num = new ArrayList();
Random random = new Random();
int size =10000;
for(int i = 0; i < size; i++){
num.add(random.nextInt(size));
}
System.out.println(num);
Collections.sort(num,new MyIntCom());
// Collections.sort(num );
System.out.println(num);
System.out.println(check(num));
}
}
}