Java Arrays类进行数组排序

 

public class MyComparatorAsc implements Comparator {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o1 - o2;
    }
}
public class MyComparatorDesc implements Comparator {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2 - o1;
    }
}

 

Arrays.sort(arrcopy, new MyComparatorAsc());

 

你可能感兴趣的:(Java)