Quick-sort (9)
To partition a[left…right] such that a[left…p–1] are all less than or equal to a[p], and a[p+1…right] are all greater than or equal to a[p]:
1. Let pivot be the value of a[left], and set p = left.2. For r = left+1, …, right, repeat: 2.1. If a[r] is less than pivot: 2.1.1. Copy a[r] into a[p], a[p+1] into a[r], and pivot into a[p+1]. 2.1.2. Increment p. 3. Terminate with answer p.
Note that other (and better) partitioning algorithms exist.