Custom sorting indices in Python3
We can create a custom sort to order pairs of indices in the array by \'Manhattan distance\' from (r0, c0).\n\n\nclass Solution:\n    def allCellsDistOrder(self
We can create a custom sort to order pairs of indices in the array by \'Manhattan distance\' from (r0, c0).\n\n```\nclass Solution:\n    def allCellsDistOrder(self, R: int, C: int, r0: int, c0: int):\n        def f(pair):\n            return abs(r0 - pair[0]) + abs(c0 - pair[1]) #returns distance from (r0, c0)\n        return sorted([[i,j] for i in range(R) for j in range(C)], key = f) #sorts result by distance\n```\n\nThis ensures our resulting array is sorted via distance from (r0, c0).
['Array', 'Sorting', 'Python3']