import java.util.*;
public class Main {
public static void main(String[] args) {
// Solution su = new Solution();
// System.out.println(su.intToRoman(111));
erweishuzupaixu(new int[][]{{1, 2, 3, 4}, {1, 1, 5, 6}, {2, 3, 4, 5}, {3, 2, 4, 1}});
}
函数测试
private static void erweishuzupaixu(int[][] arr) {
Arrays.sort(arr, new Comparator() {
@Override
public int compare(int[] o1, int[] o2) {
if (o1[0] != o2[0]) {
return o1[0] - o2[0];
} else {
if (o1[1] != o2[1]) {
return o1[1] - o2[1];
} else {
return o1[2] - o2[2];
}
}
}
});
//输出结果
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[0].length; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}