Your question is Sort Tasks by Priority and Time. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Claude Code receives a collection of tasks that must be presented in execution order. Sort the tasks by higher priority first. When two tasks have the same priority, place the task with the smaller creation_order first so older tasks are processed before newer ones.
Return a new list containing the original task dictionaries in the required order. Do not modify the input list.
Implement sort_tasks(tasks), where tasks is a list of dictionaries. Each dictionary contains:
id: a unique string identifying the taskpriority: an integer from 1 through 10, where 10 is highest prioritycreation_order: a unique non-negative integer assigned when the task was createdReturn a list of the same task dictionaries, ordered by priority descending and creation_order ascending.
def sort_tasks(tasks):