Sorting Algorithm Visualizer illustration

Sorting Algorithm Visualizer

Sorting algorithms are far easier to understand when you can watch them work. This visualizer animates the classic algorithms — bubble, selection, insertion, merge, quick, heap and shell sort — as they compare and swap coloured bars, highlighting the elements each one is currently touching. Choose an algorithm and array size, pick a starting arrangement (shuffled, nearly sorted, reversed or few-unique) and control the speed; a live counter tracks comparisons and swaps so you can compare the O(n²) sorts against the O(n log n) ones on the same data.

Runs 100% in your browser — simulations are computed locally on your device.

Notes

  • Bubble, selection and insertion sort run in O(n²) time; merge, quick and heap sort run in O(n log n) on average.
  • The comparison and swap counters make the cost gap concrete — the quadratic sorts explode as the array grows.
  • Starting arrangement matters: insertion sort is nearly linear on almost-sorted data, while naive quicksort degrades on already-sorted input.
  • Runs 100% in your browser — simulations are computed locally on your device.