✅ Simple Heap Solution | Python
Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(n)\n\n# Code\n\nfrom collections import Counter\nfrom heapq import heappop, heappush\nclass Sol
# Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(n)\n\n# Code\n```\nfrom collections import Counter\nfrom heapq import heappop, heappush\nclass Solution:\n    def frequencySort(self, nums: List[int]) -> List[int]:\n        freq = Counter(nums)\n\n        heap = []\n        for num in freq:\n            heappush(heap, (freq[num], -num))\n\n        output = []\n        while heap:\n            f, n = heappop(heap)\n            for i in range(f):\n                output.append(-n)\n        \n        return output\n        \n\n```
['Array', 'Sorting', 'Heap (Priority Queue)', 'Python3']