Quicksort

Time complexity: O(n log n) average, O(n²) worst.

Result

Examples

How it works

Quicksort picks a pivot, moves smaller values before it and larger ones after, then sorts each side the same way. A good pivot splits the list in half each time.

When to use it

General-purpose in-memory sorting. Many standard libraries use a variant of it.

Other algorithms