insights Visualizer

Sorting Visualiser

Choose a sorting algorithm and watch every comparison, swap, partition and write operation play out as animated bars.

Bubble Sort

Repeatedly compares adjacent values and swaps them when they are in the wrong order.

Sorting algorithms included

Bubble: adjacent comparisons and swaps.

Selection: finds the minimum value for each position.

Insertion: builds a sorted prefix one value at a time.

Merge: splits, sorts and merges ranges.

Quick: partitions values around a pivot.

Random Quick: chooses a random pivot before partitioning.

Radix: sorts integer values by digit from least to most significant.

Algorithm animation workflow

Sorting Visualiser for practical browser-based workflows

Use this sorting visualiser when you want to see how classic sorting algorithms move through an array instead of only reading Big-O notation. Choose bubble sort, selection sort, insertion sort, merge sort, quick sort, randomized quick sort, or radix sort, then generate a random array and watch the bars change. The page highlights comparisons, swaps, writes, and sorted positions while tracking steps, total operations, comparisons, and writes. It is useful for students, interview prep, teaching, and debugging algorithm intuition directly in the browser.

bar_chart

Animate each operation

Watch bars compare, swap, write, partition, merge, and settle into sorted positions.

speed

Control size and speed

Adjust array size, animation speed, generate fresh data, reset the same run, or step manually.

functions

Compare algorithm behavior

Use counters and motion to contrast quadratic sorts, divide-and-conquer sorts, and radix-style digit passes.

How sorting animation helps

Each bar represents one array value. When an algorithm compares two positions, writes a value, swaps a pair, chooses a pivot, or merges a range, the visualiser records that operation as a step. The stage then replays those steps so you can connect the code idea to movement on screen.

Bubble, selection, and insertion sort make many local comparisons on random data. Merge sort writes values back while combining sorted ranges. Quick sort partitions around a pivot, while randomized quick sort changes the pivot choice before partitioning. Radix sort groups positive integer values by digit rather than comparing every pair directly.

Common sorting visualiser use cases

Algorithm lessons: Show why two correct sorting methods can move through the same data very differently.

Interview prep: Rehearse the mechanics of quick sort partitioning, merge sort merging, and insertion sort shifting.

Self-study: Slow down the animation and use Step mode until each comparison and write feels predictable.

Teaching demos: Use different array sizes to make small local swaps and larger divide-and-conquer movement easier to discuss.

Counter intuition: Watch comparisons and writes rise as array size increases, without treating the page as a benchmark.

Radix sort contrast: Compare digit passes against comparison-based algorithms on positive integer bar values.

Sorting visualiser examples

On a small random array, bubble sort usually shows repeated adjacent comparisons and swaps.

Array:
[42, 17, 68, 9]

Bubble-style trace:
compare 42 and 17
swap adjacent values
compare 42 and 68
compare 68 and 9
swap adjacent values

Quick sort feels different because each partition moves values around a pivot before sorting the smaller ranges.

Quick sort idea:
choose pivot
compare each value with pivot
move smaller values left
place pivot between left and right partitions
repeat on each side

Sorting Visualiser FAQ

What does this sorting visualiser show?

This sorting visualiser shows an array as animated bars and steps through comparisons, swaps, writes, partitions, merges, and sorted positions so you can watch how the selected algorithm changes the data.

Which sorting algorithms are included?

The page includes bubble sort, selection sort, insertion sort, merge sort, quick sort, randomized quick sort, and radix sort.

Can I step through comparisons and swaps?

Yes. You can start the animation, pause it, or use the Step control to move through one recorded operation at a time. The counters show step progress, comparisons, and writes.

Is this a performance benchmark?

No. The counters and animation are teaching aids, not formal benchmarks. Browser rendering speed, animation delay, random data, and simplified implementation details can differ from production sorting behavior.

Why compare sorting algorithms visually?

Visual comparison makes algorithm behavior easier to understand. You can see slow adjacent swaps, sorted prefixes, merge writes, quick sort partitions, randomized pivots and radix digit passes instead of only reading complexity labels.

Does the visualization run in my browser?

Yes. The array generation, algorithm steps, counters, and bar animation run with JavaScript in your browser.

Learning and accuracy notes

This visualisation simplifies real implementations so the core behavior is easier to see. It does not generate formal proofs, benchmark browser performance, model every memory allocation, or represent every production optimization used by standard library sorts.

Use the counters and animation to build intuition, then verify algorithm details against source code, tests, textbooks, or course material when correctness matters. Runtime in a browser animation is affected by array size, delay settings, rendering, random input, and the simplified step recorder.