Custom sort for the Points [C++]
\n# Approach\n Describe your approach to solving the problem. \nWe simply create an array and sort it according to the given condition of minimizing the distanc
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe simply create an array and sort it according to the given condition of minimizing the distance between a point in the array and {rCenter, cCenter}. \n\nThe lambda takes 2 points `a` and `b`, and determines the order by distance of these points from the center.\n\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> allCellsDistOrder(int rows, int cols, int r, int c) {\n        vector<vector<int>> ans;\n        for (int i=0; i<rows; i++) {\n            for (int j=0; j<cols; j++)\n                ans.push_back({i, j});\n        }\n\n        sort (ans.begin(), ans.end(), [&] (auto& a, auto& b) {\n            return (abs(r-a[0]) + abs(c-a[1]) < abs(r-b[0]) + abs(c-b[1]));\n        });\n\n        return ans;\n    }\n};\n```
['C++']