Very Easy JAVA Soln | Brute Force
\n\n# Code\n\nclass Solution {\n    public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        int[][] ans=new int[rows*cols][2];
\n\n# Code\n```\nclass Solution {\n    public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n        int[][] ans=new int[rows*cols][2];\n        int idx=0;\n        for(int i=0;i<rows;i++){\n            for(int j=0;j<cols;j++){\n                ans[idx][0]=i;\n                ans[idx++][1]=j;\n            }\n        }\n\n        Arrays.sort(ans,new Comparator<int[]>(){\n            public int compare(int[] a,int[] b){\n                int x=Math.abs(a[0]-rCenter)+Math.abs(a[1]-cCenter);\n                int y=Math.abs(b[0]-rCenter)+Math.abs(b[1]-cCenter);\n                return x-y;\n            }\n        });\n\n        return ans;\n    }\n}\n```
['Sorting', 'Java']