question 131 Built-ins & Sorting · easy
Reorder the support queue in place
A help desk keeps its open tickets in one list that several screens share. Reorder that same list so urgent work comes first: priority "high", then "medium", then "low" (not alphabetical!), and within a priority the oldest ticket first. Because other screens hold the same list, change it in place and return nothing.
Function
prioritise(tickets)ticketsa list of dictionaries with
id, priority ("high", "medium" or "low") and opened ("YYYY-MM-DD HH:MM" text)Effect
tickets itself is reordered: high, medium, low; oldest first within a priorityReturns
None, like list.sortExamples
callprioritise([{'id': 'T-31', 'priority': 'low', 'opened': '2025-05-02 09:10'}, {'id': 'T-29', 'priority': 'high', 'opened': '2025-05-02 11:45'}, {'id': 'T-27', 'priority': 'medium', 'opened': '2025-05-01 16:20'}, {'id': 'T-30', 'priority': 'high', 'opened': '2025-05-02 08:05'}])returnsNone
callprioritise([{'id': 'T-1', 'priority': 'low', 'opened': '2025-01-01 00:00'}])returnsNone
callprioritise([])returnsNone