Java Self Explanatory Easy To Understand 98% Faster
\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        HashMap<Integer,Integer> map = new HashMap<>();\n        for(int i:nums) map.put(i,map
```\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        HashMap<Integer,Integer> map = new HashMap<>();\n        for(int i:nums) map.put(i,map.getOrDefault(i,0)+1);\n        int[][] arr = new int[map.size()][2];\n        int idx=0;\n        for(int i:map.keySet()){\n            arr[idx][0] = i;\n            arr[idx++][1] = map.get(i);\n        } \n        Arrays.sort(arr,(i,j) -> {if(i[1] > j[1]) return 1; if(i[1] < j[1]) return -1; if(i[0] > j[0]) return -1;return 1;});\n        idx=0;\n        for(int i=0;i<arr.length;i++){\n            while(arr[i][1]-->0) nums[idx++] = arr[i][0];\n        }\n        return nums;\n    }\n}\n```
['Java']