JAVA || Comparator || Easy to understand
\nclass Solution {\n    public int[][] allCellsDistOrder(int R, int C, int r, int c) {\n        int index = 0;\n        int[][] result = new int[R*C][2];\n     
```\nclass Solution {\n    public int[][] allCellsDistOrder(int R, int C, int r, int c) {\n        int index = 0;\n        int[][] result = new int[R*C][2];\n        \n        for(int i = 0; i < R; i++){\n            for(int j = 0; j < C; j++){\n                result[index][0] = i;\n                result[index][1] = j;\n                index++;\n            }\n        }\n        \n        Arrays.sort(result, (a, b)-> \n            (Math.abs(r-a[0])+Math.abs(c-a[1])) - (Math.abs(r-b[0])+Math.abs(c-b[1]))\n        );\n        \n        return result;\n    }\n}\n```
['Java']