文章目录
数组
Arrays.sort(properties, (o1, o2) -> {
return o1[0] == o2[0] ? (o2[1] - o1[1]) : (o1[0] - o2[0]);
});
按第0维升序排序,第0维相同时按第1维降序排序。
e.g.
int[][] arr = {{1, 5}, {10, 4}, {4, 3}, {4, 4}};
System.out.println(Arrays.deepToString(arr));
Arrays.sort(arr, (o1, o2)-> o1[0] == o2[0] ? o2[1] - o1[1]: o1[0] - o2[0]);
System.out.println(Arrays.deepToString(arr));
[[1, 5], [10, 4], [4, 3], [4, 4]]
排序后
[[1, 5], [4, 4], [4, 3], [10, 4]]