Quicksort

Assuming you are sorting from (left to right) least to most, then when the GT index crosses the LT index, then you need to swap the partition value with the GT index value. Or when the LT index reaches the GT index, do the same.

You can choose an random partition, and then swap it with the first location in the array. This gives better results than simply choosing the first element as the partition value.

one version of quicksort in C++