Java straighforward
class Solution {\n    \n    public int[][] allCellsDistOrder(int R, int C, int r0, int c0) {\n        List<int[]> result = new ArrayList<int[]>();\n        \n  
```class Solution {\n    \n    public int[][] allCellsDistOrder(int R, int C, int r0, int c0) {\n        List<int[]> result = new ArrayList<int[]>();\n        \n        for (int i = 0; i < R; i++) {\n            for (int j = 0; j < C; j++) {\n                int[] tmp = new int[2];\n                \n                tmp[0] = i;\n                tmp[1] = j;\n                \n                result.add(tmp);\n            }\n        }\n        \n        Collections.sort(result, new Comparator<int[]>() {\n            public int compare(int[] a, int[] b) {\n                int l1 = Math.abs(a[0] - r0) + Math.abs(a[1] - c0);\n                int l2 = Math.abs(b[0] - r0) + Math.abs(b[1] - c0);\n                \n                return l1 - l2;\n            }\n        });\n        \n        int[][] arr = result.toArray(new int[result.size()][2]);\n        \n        return arr;\n    }\n}```
[]