Advanced workspace · algorithms

Sorting Algorithm Visualizer

Full workspace

Watch 15 sorting algorithms work step by step, from bubble sort to quicksort, heapsort and radix sort. Race up to four of them on the same data, count every comparison, swap and write, scrub back and forth through the run, and hear the values as tones. Try random, nearly sorted, reversed or your own numbers to see where each algorithm shines or struggles, then export a video with sound, a GIF or a report.

  • 15 algorithms
  • Race up to 4
  • Step, scrub & replay
  • Comparisons, swaps & writes
  • Bars, dots, colour & circle
  • Sound of sorting
  • MP4 with sound · GIF · PDF
Live sort–
Algorithm
–
Values
–
Compares
–
Leader
–

Export

Videos and the GIF replay the whole race from the start; the PNG and SVG show the current moment. Sound follows the values being touched, like the classic "sound of sorting" videos.

Each algorithm really runs on your data in the browser, and every comparison, swap and write is recorded, so the counts are exact, not estimates.

Keyboard shortcuts

Using Sorting Algorithm Visualizer

Watch, step through and race 15 sorting algorithms on the same data.

  1. The page opens on a race between quicksort, merge sort, heapsort and bubble sort on 64 shuffled values. Press Play or Space to start or pause it.
  2. Pink marks a comparison, gold a swap or write, teal the pivot, and green a value already in its final place.
  3. Change any lane's algorithm with the picker above it, add lanes in the Race tab (up to four) or remove one with its cross.
  4. Pick the starting order: random, nearly sorted, reversed, few unique values, sorted, sawtooth, organ pipes or your own numbers. Set how many values with the Values box.
  5. Step one comparison at a time with the arrow keys, or drag the timeline to any moment. The counters show the exact comparisons, swaps and writes so far.
  6. Turn on Sound to hear each touched value as a tone, and switch the style between bars, dots, a colour strip and a circle in the View tab.
  7. Export the race as an MP4 or WebM video with sound, a GIF, a PDF report, a work chart, the results or a step log as CSV, or the algorithm's code.

Example

Load Quicksort worst case: on already sorted data, quicksort with the last value as pivot needs 8,128 comparisons for 128 values, while the median-of-three version needs only about a thousand.

Questions & answers

Which sorting algorithm is the fastest?

It depends on the data. Quicksort is usually fastest on random data, insertion sort wins on nearly sorted data, and counting or radix sort beat them all on small whole numbers because they never compare.

What does stable mean?

A stable sort keeps equal values in the order they started. That matters when you sort by one column and then another, for example by surname and then by city.

Why is bubble sort so slow?

It only swaps neighbours, so a value at the wrong end needs up to n swaps to get home, about n²/2 comparisons in all.

Are the counts real?

Yes. Each algorithm really runs on your data and every comparison, swap and write is recorded and replayed.

What does equal time mean in a race?

Every comparison and write takes one tick and a swap takes two, so the algorithm with the least work finishes first. One step each instead gives every lane one recorded step per tick.

Why does bitonic sort change the number of values?

Bitonic sort is a sorting network that works on power-of-two sizes, so the data is cut to 32, 64, 128 or 256 values while it is in the race.

Help improve this tool

Report a problem or suggest an improvement

Describe the issue without pasting private tool input. Feedback goes to our admin inbox.

Find another tool · Read practical guides