grokking-algorithms/chapter9/examples/heaptest.py

11 lines
244 B
Python

import heapq
customers = []
heapq.heappush(customers, (2, "Harry"))
heapq.heappush(customers, (3, "Charles"))
heapq.heappush(customers, (1, "Riya"))
heapq.heappush(customers, (4, "Stacy"))
while customers:
print(heapq.heappop(customers))