您的位置:首页 > 其它

数组----三谈二维数组的排序

2014-02-21 21:55 267 查看
static int[][] seq_int = {
{2349,12,420,549,120,3,23},
{1,30,84,693,29,4,4},
{7,239,943,82,32,492},
{2,4,234,5920,2019,40234},
{5,603,582,6928,923752,234},
{9,509,2392,95,102,402,2}
};

public static void main(String[] args) {

Arrays.sort(seq_int, new Comparator<int[]>(){
public int compare(int[] o1, int[] o2) {
Arrays.sort(o1);
Arrays.sort(o2);
return o1[0] - o2[0];
}
});

System.out.println(Arrays.deepToString(seq_int));

}


output: [[1, 4, 4, 29, 30, 84, 693], [2, 4, 234, 2019, 5920, 40234], [2, 9, 95, 102, 402, 509, 2392], [3, 12, 23, 120, 420, 549, 2349], [5, 234, 582, 603, 6928, 923752], [7, 32, 82, 239, 492, 943]]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: