Easy to Understand | Simple | Faster | 2 solutions | Counting sort | Python
\ndef using_counting_sort(self, R, C, r0, c0):\n        out = [[] for _ in range(R + C)]\n        for i in range(R):\n            for j in range(C):\n          
```\ndef using_counting_sort(self, R, C, r0, c0):\n        out = [[] for _ in range(R + C)]\n        for i in range(R):\n            for j in range(C):\n                diff = abs(i - r0) + abs(j - c0)\n                out[diff].append([i, j])\n        ret = []\n        for arr in out:\n            ret.extend(arr)\n        return ret\n        \n    def brute_force(self, R, C, r0, c0):\n        out = []\n        for i in range(R):\n            for j in range(C):\n                out.append({\n                    "dist": abs(i - r0) + abs(j - c0),\n                    "val": [i, j]\n                })\n        return [i[\'val\'] for i in sorted(out, key=lambda x: x[\'dist\'])]\n```\n\n**I hope that you\'ve found the solution useful.**\n*In that case, please do upvote and encourage me to on my quest to document all leetcode problems\uD83D\uDE03*\nPS: Search for **mrmagician** tag in the discussion, if I have solved it, You will find it there\uD83D\uDE38
['Sorting', 'Counting Sort', 'Python', 'Python3']