JAVA easy solution using comparator
\nclass Solution {\n    public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        int a[][]=new int[rows*cols][2];//for storing 
```\nclass Solution {\n    public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        int a[][]=new int[rows*cols][2];//for storing coordinates\n        int k=0;\n        for(int i=0;i<rows;i++)\n        {\n            for(int j=0;j<cols;j++)\n            {\n                a[k][0]=i;\n                a[k][1]=j;\n                k+=1;\n            }\n        }\n        Arrays.sort(a,new Comparator<int[]>()\n                    {\n                        @Override\n                        public int compare(int a[],int b[])\n                        {\n                            int d1=(int)Math.abs(a[0]-rCenter)+(int)Math.abs(a[1]-cCenter);//distance of first point\n                            int d2=(int)Math.abs(b[0]-rCenter)+(int)Math.abs(b[1]-cCenter);//distance of second point\n                            if(d1>d2)return 1;\n                            else if(d1<d2)return -1;\n                            else return 0;\n                        }\n                    });\n        return a;\n        \n    }\n}\n```
['Java']