mirror of
https://github.com/onyx-and-iris/grokking-algorithms.git
synced 2024-11-15 17:30:52 +00:00
15 lines
440 B
Python
15 lines
440 B
Python
|
customers = []
|
||
|
customers.append((2, "Harry")) # no sort needed here because 1 item.
|
||
|
customers.append((3, "Charles"))
|
||
|
customers.sort(reverse=True)
|
||
|
# Need to sort to maintain order
|
||
|
customers.append((1, "Riya"))
|
||
|
customers.sort(reverse=True)
|
||
|
# Need to sort to maintain order
|
||
|
customers.append((4, "Stacy"))
|
||
|
customers.sort(reverse=True)
|
||
|
|
||
|
while customers:
|
||
|
print(customers.pop(0))
|
||
|
# Will print names in the order: Stacy, Charles, Harry, Riya.
|