Algorithm
Input
unsortedcomparingwritingin final position
0
comparisons
0
writes
0 / 16
in place

Quick sort: pick a pivot, move everything smaller to its left, then recurse on each side.

Step 1 of 78
Quick sort

Usually the fastest in practice thanks to cache behaviour, but the worst case is real without a good pivot.

best O(n log n)average O(n log n)worst O(n²)space O(log n)not stablein place
On this exact inputComparisonsWritesWorst case
Bubble sort117114O(n²)
Selection sort12026O(n²)
Insertion sort6972O(n²)
Merge sort4664O(n log n)
Quick sort4246O(n²)
Heap sort85112O(n log n)
Counting sort016O(n + k)

Counting sort runs on a smaller value range than the others, since it needs one bucket per distinct value.

Sorting Algorithm Visualizer · Built with Nandscape