Interactive sorting laboratory

Sorting Algorithms, Step by Step

Compare how ten fundamental sorting methods inspect, move, divide, distribute, and finally order the same data. Every step explains the active operation and updates the cost counters.

7 comparison sorts 3 distribution sorts custom input operation counters live pseudocode

Explore one algorithm at a time

Select a method, enter up to 12 non-negative integers, and use the controls to study every meaningful operation.

Comparison sort
READY Choose an algorithm, then press Play or Step. 0 / 0
Live pseudocode current step
compare / inspect move / swap candidate / auxiliary sorted / fixed
Auxiliary state
This area will show temporary arrays, gaps, heap boundaries, counts, digits, or buckets when the selected method needs them.
At a glance

Choose the right sorting method

The table states the standard textbook bounds. Actual performance also depends on input order, implementation details, cache behavior, pivot choice, and gap sequence.

AlgorithmFamilyBestAverageWorstExtra spaceStable?In place?
Bubble SortcomparisonO(n)O(n²)O(n²)O(1)YesYes
Selection SortcomparisonO(n²)O(n²)O(n²)O(1)NoYes
Insertion SortcomparisonO(n)O(n²)O(n²)O(1)YesYes
Merge SortcomparisonO(n log n)O(n log n)O(n log n)O(n)YesNo
Quick SortcomparisonO(n log n)O(n log n)O(n²)O(log n) average stackNoYes
Heap SortcomparisonO(n log n)O(n log n)O(n log n)O(1)NoYes
Shell SortcomparisonDepends on gapsDepends on gapsO(n²)O(1)NoYes
Counting SortdistributionO(n + k)O(n + k)O(n + k)O(n + k)YesNo
Radix SortdistributionO(d(n + b))O(d(n + b))O(d(n + b))O(n + b)YesNo
Bucket SortdistributionO(n + k)O(n + k)O(n²)O(n + k)Can beNo
1

Watch the invariant

Green values satisfy the algorithm’s current guarantee: a sorted suffix, sorted prefix, fixed pivot, completed merge, or finished output position.

2

Read the auxiliary state

Merge uses temporary storage; Shell exposes its gap; Heap shows the active heap; Counting, Radix, and Bucket Sort reveal their distribution structures.

3

Compare the counters

Run the same array through different methods. The counters make comparisons, swaps, and writes concrete without pretending that every operation has identical machine cost.