Java Arrays.sort() solution with Comparator
\nclass Solution {\n    public int[][] allCellsDistOrder(int R, int C, int r0, int c0) {\n        int[][] res = new int[R * C][2];\n        int count = 0;\n    
```\nclass Solution {\n    public int[][] allCellsDistOrder(int R, int C, int r0, int c0) {\n        int[][] res = new int[R * C][2];\n        int count = 0;\n        \n        for(int i = 0; i < R; i++){\n            for(int j = 0; j < C; j++) res[count++] = new int[]{i, j};\n        }\n        \n        Arrays.sort(res, Comparator.comparingInt(a -> \n            Math.abs(a[0] - r0) + Math.abs(a[1] - c0)));\n        return res;\n    }\n}\n```
[]