This one is very easy and safe way: Assume: int[][]arr=new int[3][4]; Arrays.sort(arr, (a,b)->Integer.Compare(a[0],b[0]));