Sorting is one of the most useful Bronze tools because many story problems become easier when events are processed in time order or value order.
Scenario: room usage events
Suppose a fictional contest problem gives start and end times for club room reservations. The task is to find the maximum number of rooms in use at once.
events = []
for start, end in reservations:
events.append((start, 1))
events.append((end, -1))
events.sort()
current = 0
best = 0
for time, change in events:
current += change
best = max(best, current)
Why sorting helps
Without sorting, the program sees reservations in input order, which may not match time order. Sorting creates a timeline. Then the loop only needs to update the current count.
Common edge case
If one event ends at the same time another begins, students must know whether those overlap. The problem statement controls the rule. In a real contest, this detail can change the answer.
Practice prompt
Make a five-reservation example and manually build the sorted event list. Trace current and best after each event.
