Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Sorting algorithm race

Race up to four sorting algorithms on the same data and watch the bars move: bubble, insertion, selection, shell, merge, quick, heap, radix and more.

How to use

  1. Pick up to four algorithms. They all sort exactly the same values.
  2. Choose how many values and how they start: shuffled, nearly sorted, reversed, with few different values, or already sorted.
  3. Press Play and watch. The orange bars are being compared or moved. One step moves every racer forward by one action.
  4. Compare the counters: comparisons and writes show the real work, which matters more than the time on screen.

Keyboard and touch

TabMove between the choices and buttons
Enter / SpacePlay, pause or step
← →Change the speed (on the slider)

Tips

  • Try Already sorted: insertion and bubble sort finish almost at once, while selection sort still does all its comparisons.
  • Try Reversed: the simple sorts slow down a lot; merge, heap and quick sort hardly notice.
  • Bubble, insertion and selection sort grow with n²: twice the values means about four times the work. Merge, heap and quick sort grow with n log n.
  • Radix sort does not compare values at all; it sorts digit by digit.

About the race

Each algorithm sorts a copy of the data once while every comparison, swap and write is recorded; the race then replays the recordings at the same speed, so each lane moves at the rate of its own work. Quick sort uses Hoare's partition with a median-of-three pivot; shell sort uses Ciura's gap sequence; radix sort works in base 10. The tests check that every algorithm sorts correctly and count their work on known cases.

With “reduce motion” set on your device, results are shown at once without animation. Nothing is stored or sent.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product