✅ Java - Simple HashMap & PriorityQueue Solution
\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        //init hashmap and count occurences of elements in nums\n        //init minHeap based 
```\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        //init hashmap and count occurences of elements in nums\n        //init minHeap based on occurence, if two elements have same freq sort in decreasing order\n        //add elements in map into minHeap as array, containing element and occurence\n\t\t//init index to traverse array\n        //loop while minHeap is not empty\n        //grab min element \n        //keep inserting element into nums while in bounds and occurence > 0\n        //return nums\n        \n        Map<Integer, Integer> map = new HashMap<>();\n        \n        for(int i : nums)\n        {\n            map.put(i, map.getOrDefault(i, 0) + 1);\n        }\n        \n        PriorityQueue<int[]> minHeap = new PriorityQueue<>((a,b) -> a[1] == b[1] ? b[0] - a[0] : a[1] - b[1]);\n        \n        for(Map.Entry<Integer, Integer> entry : map.entrySet())\n        {\n            minHeap.add(new int[] {entry.getKey(), entry.getValue()});\n        }\n        \n        int index = 0;\n        \n        while(!minHeap.isEmpty())\n        {\n            int[] min = minHeap.poll();\n            \n            while(index < nums.length && min[1] > 0)\n            {\n                nums[index++] = min[0];\n                min[1]--;\n            }\n        }\n        \n        return nums;\n    }\n}\n```
['Heap (Priority Queue)', 'Java']