使用Lambda表达式进行排序:
class Solution {
Integer[] list = new Integer[]{8,3,4,9,5,2};
//从小到大排序
Arrays.sort(list);
//从大到小1
list = new Integer[]{8,3,4,9,5,2};
Arrays.sort(list,(a,b) -> -a.compareTo(b));
//从大到小2
list = new Integer[]{8,3,4,9,5,2};
Arrays.sort(list,(a,b) -> -Integer.compare(a,b));
//从大到小3
list = new Integer[]{8,3,4,9,5,2};
Arrays.sort(list,(a,b) -> -(a-b));
//二维数组按照第一维度大小进行排序
//假设list1是个二维数组
Arrays.sort(list1, (a, b) -> Integer.compare(a[0], b[0]));
}