Java Solution with MinHeap and HashMap
\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        Map<Integer, Integer> map = new HashMap<>();\n        int sortedArr[] = new int[nums.l
```\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        Map<Integer, Integer> map = new HashMap<>();\n        int sortedArr[] = new int[nums.length];\n        for(int num: nums) {\n            map.put(num, map.getOrDefault(num, 0) + 1);\n        }\n        Queue<Integer> minHeap = new PriorityQueue<Integer>((a,b)-> (map.get(a) == map.get(b)) ? b-a: map.get(a)-map.get(b) );\n        for(int num: nums) {\n            minHeap.add(num);\n        }\n        int i=0;\n        while(!minHeap.isEmpty()) {\n            sortedArr[i++] = minHeap.remove();\n        }\n        \n        return sortedArr;\n    }\n}\n```
[]