2
def getOrder(self, tasks: List[List[int]]) -> List[int]:3
# For better readability4
Task = namedtuple("Task", ["etime", "ptime", "index"])6
# Sort the tasks by enqueue time, shortest processing time and index7
stasks = sorted([Task(task[0], task[1], i) for i, task in enumerate(tasks)])8
# t: current CPU clock; i: current task index12
while len(result) < len(stasks):13
# Push all the tasks available at current CPU clock14
while i < len(stasks) and stasks[i].etime <= t:15
heappush(heap, (stasks[i].ptime, stasks[i].index))18
ptime, index = heappop(heap)22
# Jump to the next available task