Partition around a pivot for quicksort
Quicksort picks a pivot, moves smaller items before it and larger items after it, then sorts the two sides. The pivot is already in its final place after partitioning.
items = [7, 2, 9, 4]
pivot = items[-1] # 4
less = [x for x in items if x < pivot]
print(less) # [2]Think before coding
With a fair pivot, each level halves the work and the total is n log n. Grouping values equal to the pivot separately prevents the slowdown on lists full of duplicates. Work through the example by hand before changing the starter. Decide what should happen for an empty input, a single value and a repeated value where those cases apply. The checks use several inputs so a hard-coded answer cannot stand in for the rule.
Your task
Write quicksort(items) returning a new sorted list. Partition into less, equal and greater lists around a pivot and recurse on less and greater.
The explanation opens here once every check passes.