Using helper function & sort
\nclass Solution:\n    def allCellsDistOrder(self, rows: int, cols: int, rCenter: int, cCenter: int) -> List[List[int]]:\n        # create a r, c matrix given t
```\nclass Solution:\n    def allCellsDistOrder(self, rows: int, cols: int, rCenter: int, cCenter: int) -> List[List[int]]:\n        # create a r, c matrix given the rows & cols\n        # each element represents a list [r, c] where r is the row & c the col\n        # find find the distances of all cells from the center (append to res)\n        # sort the result by distance function\n        # Time O(M + N) Space O(M + N)\n        \n        \n        def distance(p1, p2):\n            return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])\n        \n        matrix = [[i, j] for i in range(rows) for j in range(cols)]\n        center = [rCenter, cCenter]\n        matrix.sort(key=lambda c: distance(c, center))\n        \n        return matrix\n```
['Python', 'Python3']