Sorting algorithms

100 numbers, 6 algorithms. Watch them sort together.

Elements Active CompletePlayed 0.0 s · same input

Bubble sort

Bubble sort
O(n²)
Operations0
Comparisons0
Writes0

Selection sort

Selection sort
O(n²)
Operations0
Comparisons0
Writes0

Insertion sort

Insertion sort
O(n²)
Operations0
Comparisons0
Writes0

Merge sort

Merge sort
O(n log n)
Operations0
Comparisons0
Writes0

Quick sort

Quick sort
O(n log n)
Operations0
Comparisons0
Writes0

Heap sort

Heap sort
O(n log n)
Operations0
Comparisons0
Writes0

Each comparison or write counts as 1 operation. Playback time is not execution time.

How it works +

All algorithms use the same integers, with 20, 50, 100 or 200 elements. Each comparison or main-array write counts as 1 operation; a swap usually needs 2 writes. Temporary storage and loop control are excluded.

Operation counts illustrate the algorithms; playback time is not execution time. Yellow marks active elements and green marks completion.