def test_simple(): heap = HeapMax() items_priority = [15, 12, 9, 14, 8, 3, 7, 13, 11, 5] items_priority2 = [3, 3, 3, 5, 5, 5, 0, 9] random.shuffle(items_priority) for idx, priority in enumerate(items_priority): heap.insert(HeapItem(priority, f'item {idx + 1}')) print(heap)
def heap_sort(source: List[int]) -> List[int]: heap = HeapMax() for i in source: heap.insert(HeapItem(i, None)) return [heap.get_item_max().priority for _ in range(heap.size())]