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

    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]]

posted @ 2014-02-21 21:55  小菜喵  阅读(147)  评论(0编辑  收藏  举报