Integer[] arr = {10, 12, 45, 78, 551, 36, 45, 21};
// Comparator 比较器对象
Arrays.sort(arr);
System.out.println("Arrays.toString(arr) = " + Arrays.toString(arr));
// 降序
Arrays.sort(arr, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o2-o1;
}
});
System.out.println("Arrays.toString(arr) = " + Arrays.toString(arr));
}