1import heapq234class Solution:5def sortArray(self, nums: List[int]) -> List[int]:67h = {}8for i in nums:9if i in h:10h[i] += 111else:12h[i] = 11314heap = []15for i in h:16heap.append([i, h[i]])1718heapq.heapify(heap)19ans = []2021while heap:22x = heapq.heappop(heap)23ans.append(x[0])24if x[1] > 1:25heapq.heappush(heap, [x[0], x[1] - 1])2627return ans