Matrix Cells in Distance Order
class Solution {\n    public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        int[][] arr=new int[rows*cols][2];\n        for(
class Solution {\n    public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        int[][] arr=new int[rows*cols][2];\n        for(int i=0;i<rows;i++){\n            for(int j=0;j<cols;j++){\n                int idx=i*cols+j;\n                arr[idx][0]=i;\n                arr[idx][1]=j;\n            }\n        }\n        Arrays.sort(arr,(a,b)->{\n         int d1=Math.abs(a[0]-rCenter)+Math.abs(a[1]-cCenter);\n         int d2=Math.abs(b[0]-rCenter)+Math.abs(b[1]-cCenter);\n            return d1-d2;\n        });\n        return arr;\n    }\n}
['Sorting', 'Java']