[Java] Solution using custom Sort
\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        Map<Integer, Integer> map = new HashMap<>();\n        for (int i : nums)\n            
```\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        Map<Integer, Integer> map = new HashMap<>();\n        for (int i : nums)\n            map.put(i, map.getOrDefault(i,0) + 1);\n        List<Map.Entry<Integer, Integer>> list = new ArrayList(map.entrySet());\n        Collections.sort(list, (a,b) -> a.getValue() == b.getValue() ? b.getKey() - a.getKey() : a.getValue() - b.getValue());\n        int j = 0;\n        int[] res = new int[nums.length];\n        for (Map.Entry<Integer, Integer> entry : list) \n            for (int i=0; i<entry.getValue(); i++) res[j++] = entry.getKey();\n        return res;\n    }\n}\n```
['Java']