c++ | easy | short
\n\n# Code\n\nclass Solution {\npublic:\n    vector<vector<int>> allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        vector<vector<int>> 
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        vector<vector<int>> ans;\n        for (int r = 0; r < rows; r++) {\n            for (int c = 0; c < cols; c++) {\n                ans.push_back({r, c});\n            }\n        }\n\n        sort(ans.begin(), ans.end(), DistFromCenterSorter(rCenter, cCenter));\n        return ans;\n    }\n\nprivate:\n    struct DistFromCenterSorter {\n        int rCenter;\n        int cCenter;\n        DistFromCenterSorter(int rCenter, int cCenter) {\n            this->rCenter = rCenter;\n            this->cCenter = cCenter;\n        }\n\n        bool operator()(const vector<int>& cell1, const vector<int>& cell2) {\n            return distFromCenter(cell1) < distFromCenter(cell2);\n        }\n\n        int distFromCenter(const vector<int>& cell) {\n            return abs(cell[0] - this->rCenter) + abs(cell[1] - this->cCenter);\n        }\n    };\n};\n```
['C++']