Swift Solution
Intuition\nCalculate distance for every cell and sort by this distance.\n\n# Approach\nCalculate distance from center cell for every other cell in matrix, and p
# Intuition\nCalculate distance for every cell and sort by this distance.\n\n# Approach\nCalculate distance from center cell for every other cell in matrix, and put to array along with each cell coordinates. Then sort array by distance and get only cells coordinates from this array.\n\n# Complexity\n- Time complexity:\nO(rows X cols) Because we iterate all elements in matrix\n\n- Space complexity:\nO(rows X cols) Because we store all elements\n\n# Code\n```\nclass Solution {\n    func allCellsDistOrder(_ rows: Int, _ cols: Int, _ rCenter: Int, _ cCenter: Int) -> [[Int]] {\n        var cells: [(cell: [Int], dist: Int)] = [] \n        for i in 0..<rows {\n            for j in 0..<cols {\n                let dist = abs(i - rCenter) + abs(j - cCenter)\n                cells.append(([i, j], dist))\n            }\n        }\n        return cells.sorted(by: { $0.dist < $1.dist }).map { $0.cell }\n    }\n}\n```
['Swift']