Dutch national flag partitioning groups all pivot-equal values in one pass. Recursion skips the equal group, which helps duplicate-heavy inputs.
Choose a pivot from the current range.
Keep three regions: smaller, equal, and larger values.
Recurse only on the smaller and larger regions.