Process by priority
orders is a list of (priority, name) tuples, lower meaning more urgent,
with no two sharing a priority. Write in_priority_order(orders) that returns
the names in the order they should be processed, most urgent first, using
a heap: push them all, then pop until empty.
in_priority_order([(3, "bread"), (1, "wedding cake"), (2, "sandwiches")])
-> ["wedding cake", "sandwiches", "bread"]
import heapq
def in_priority_order(orders):
heap = []
for order in orders:
...
result = []
while heap:
...
return result