<s>[INST] import heapq

def heapSort(arr):
    heapq.heapify(arr)
    return [heapq.heappop(arr) for _ in range(len(arr))]

# Driver code
if __name__ == "__main__":
    arr = [12, 11, 13, 5, 6, 7]
    print("Sorted array is")
    print(heapSort(arr))

# This code does not sort the entire array when arr=[12, 11, 13, 5, 6, 7]
# The problem is that the input array is not a heap
# The question is what is the time complexity of above code
# if we convert the array to a heap in-place (assuming this is the requirement)
# then we use the heapSort function
# What is the time complexity of the above code
# Is it O(nlogn)?[/INST]