Quick-sort counts as an in-place sort, yet partitioning into new lists $L$, $E$ and $G$ needs extra memory. How does quick-sort partition inside the array?
Take the last element as pivot and move two indices towards each other: the left one stops at an element $\ge$ the pivot, the right one at an element $\le$ the pivot; swap those two and carry on. When the indices have crossed, swap the pivot into the left index's position: smaller elements end up to its left, larger ones to its right.
* Each swap fixes two misplaced elements at once. *
Trace with 85 24 63 45 17 31 96 50 and the pivot 50:
- The left index stops at 85, the right one at 31: swap, giving 31 24 63 45 17 85 96 50.
- The left index stops at 63, the right one at 17: swap, giving 31 24 17 45 63 85 96 50.
- The left index moves past 45 and stops at 63, which is beyond the right index: the scans have crossed.
- Swap 63 with the pivot: 31 24 17 45, then 50, then 85 96 63.
The recursion then continues on index ranges of the same array (positions 0 to 3 and 5 to 7) instead of on new lists, so the only extra memory is the recursion stack, about $\log n$ frames deep when the splits are balanced. The price: swapping elements across long distances scrambles the order of equal keys, so in-place quick-sort is not stable.
Go deeper:
Quicksort: Hoare partition scheme โ the original two-index partition and the simpler one-index variant by Lomuto.