Your question is Tiered Task Queue Scheduler. 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.
Design a task queue that supports prioritized scheduling by user tier. Implement a function that processes a list of operations on tasks, where each task has a unique task_id, a tier, and an insertion order. Higher tiers must be served before lower tiers, and tasks within the same tier must be served in first-in-first-out order. Support enqueue, dequeue, and cancel by task_id, returning the results of dequeue operations.
def process_task_queue(operations):