(...done...)= items already sorted and (less dups) output p= the pivot or a duplicate of it b= "before", things known to be "less than" the pivot a= "after", things known to be "greater than" the pivot u= unsorted items (but fit within the current partition) n= next item to compare to our pivot (...to-do...)= the partitions to sort after we output this one (...done...) b b b b b u u u u u n p a a a a a p p p (...to-do...) if n is a "b", swap: b<------->u if n is an "a", swap: p-a if n is a "p", swap: p a<------->p