1、Comparator实现
import java.util.*;
class DecentComparator implements Comparator<Integer>{
public int compare(Integer o1, Integer o2) {
return o2 - o1;
}
}
2、使用时注意必须用int的封装类Integer才能比较
Integer[] a ={1,2,3,4};
Arrays.sort(a,new DecentComparator());