PythiloMedium · 25 min · Task 54 of 100 · progress kept in this browser

Partition three colors

Return a sorted copy of a list containing only 0, 1 and 2, using one traversal and constant auxiliary space apart from the copy.

items = [2, 0, 1]
mid, high = 0, 2
items[mid], items[high] = items[high], items[mid]
print(items)  # inspect mid again
Your task

Return a sorted copy of a list containing only 0, 1 and 2, using one traversal and constant auxiliary space apart from the copy.