Simple C++ Solution
1\u3001calculate the distance\n2\u3001sort by distance\n3\u3001remove the distance\n\n\nclass Solution {\npublic:\n    vector<vector<int>> allCellsDistOrder(int
1\u3001calculate the distance\n2\u3001sort by distance\n3\u3001remove the distance\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> allCellsDistOrder(int R, int C, int r0, int c0) {\n        vector<vector<int>> ans;\n        for (int i = 0; i < R; i++)\n            for (int j = 0; j < C; j++)\n                ans.push_back({i, j, abs(i - r0) + abs(j - c0)});\n\n        sort(ans.begin(), ans.end(), [](vector<int>& c1, vector<int>& c2) {\n            return c1[2] < c2[2];\n        });\n\n        for (vector<int>& d: ans) \n            d.pop_back();\n\n        return ans;\n    }\n};\n```
['C']