Data Structure 📂 Sorting & Order Statistics · 10 of 10 19 min read

Sorting Visualiser Game — Bubble, Selection, Insertion, Merge, Heap & Radix

An interactive sorting game: enter up to 10 numbers, pick an algorithm, and watch the bars sort step by step — comparing (amber), moving (red), and locking in place (green). Live counters show comparisons, moves, and total operations so learners can feel why some sorts are faster than others, including how radix sorts with zero comparisons. Includes a how-to guide and a complexity comparison table. No code, theme-aware (light & dark).

Sorting Lab

Sorting Visualiser — Bubble · Selection · Insertion · Merge · Heap · Radix

Type up to 10 numbers, choose a sorting algorithm, and press Play. Watch the bars compare (amber), move (red), and lock into place (green) step by step. The stats track exactly how many operations each algorithm needs — the best way to feel why some sorts are faster than others.

Numbers Algorithm
Unsorted Comparing Moving Sorted
 
Press Play or Step ▶ to begin.
0Comparisons
0Moves
0Total ops
0 / 0Step

Guide

How to Play

🎮 Four Steps
1
Type your own numbers in the box (commas or spaces) and click Apply — or hit Random for a fresh set.
2
Pick a sorting Algorithm from the dropdown.
3
Press Play to animate, or Step ▶ / Back to move one operation at a time. Use the Speed slider to slow it down.
4
Read the Comparisons, Moves and Total ops counters — that's the effort the algorithm spent.
💡
Try This Experiment

Run the same 10 numbers through every algorithm and compare the Total ops. You'll see Bubble and Selection do the most comparisons, Insertion shine on nearly-sorted input, and Merge and Heap stay efficient. Radix does zero comparisons — it sorts purely by looking at digits.


Reference

How Much Effort Each Sort Uses

AlgorithmBestAverage / WorstSpaceStableHow it works
BubbleO(n)O(n²)O(1)YesSwap adjacent pairs; biggest bubbles up
SelectionO(n²)O(n²)O(1)NoPick the smallest, place it, repeat
InsertionO(n)O(n²)O(1)YesInsert each item into the sorted left part
MergeO(n log n)O(n log n)O(n)YesSplit in half, sort, then merge
HeapO(n log n)O(n log n)O(1)NoBuild a max-heap, pull the max repeatedly
RadixO(d·n)O(d·n)O(n + k)YesSort by each digit, least significant first

n = how many numbers, d = number of digits, k = digit range (10).

🧮
The Takeaway

The O(n²) sorts (Bubble, Selection, Insertion) are simple but their operation count grows fast. Merge and Heap scale far better at O(n log n). Radix can beat them all when numbers have few digits, because it never compares values — it just buckets digits.

You have completed Sorting & Order Statistics. View all sections →