# Sorting Algorithm Visualizer - Animated Sorts & Race Mode

> Watch 14 sorting algorithms animate: bubble, insertion, shell, merge, quick, heap, counting, radix, bucket and Timsort, with counters, step mode and races.

- URL: https://qilingtools.com/en/sorting-visualizer
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Education](https://qilingtools.com/en/tags/education), [Charts & Visualization](https://qilingtools.com/en/tags/chart), [Developer](https://qilingtools.com/en/tags/dev), [Algorithms](https://qilingtools.com/en/tags/algorithm)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

See how sorting algorithms really work with an animated bar chart. Fourteen algorithms are built in: bubble, cocktail shaker, comb, selection, insertion, Shell sort (Ciura gaps), merge sort, quicksort with both Lomuto and Hoare partitioning, heap sort, counting sort, LSD radix sort, bucket sort and a simplified Timsort. Each one is written as a generator that emits an event for every comparison, swap or write, and the animation replays those events one by one, so every frame matches the real code exactly: yellow means comparing, red means swapping or writing, blue means reading, and a green sweep marks the finished array. Set the array size (up to 1,000 elements), the input (random, sorted, reversed, nearly sorted or few unique values) and the speed, or pause and step through one event at a time, while live counters track comparisons, swaps, writes and total steps. Turn on sound to hear each element’s value as pitch and pick up the rhythm of each algorithm. Race mode runs 2–4 algorithms side by side on the same data and ranks them as they finish — a vivid way to see O(n²) versus O(n log n), or how quicksort copes with many duplicates. A table at the bottom compares best, average and worst-case time, extra space and stability for every algorithm.

## How to use

1. Pick an algorithm (or switch to race mode and choose 2–4), then set the array size and input pattern
2. Press play to watch, adjust the speed, or pause and step through events
3. Compare the comparison, swap and write counts and the finishing order, and check the complexity table

## Features

- 14 algorithms including bubble, insertion, shell, merge, quicksort (Lomuto/Hoare), heap, counting, radix, bucket and Timsort
- Colour-coded compares, swaps, writes and reads
- Live counters for comparisons, swaps and writes
- Adjustable size, 5 input patterns, speed and single-step mode
- Race 2–4 algorithms side by side with rankings
- Optional sound with pitch mapped to value
- Time and space complexity and stability table
- Generator-based algorithms, so the animation matches real execution step for step

## FAQ

### Which sorting algorithm is the fastest?

No algorithm wins everywhere. On random data quicksort, merge sort and heap sort are all O(n log n), and quicksort usually wins thanks to its small constant factor. On nearly sorted data insertion sort and Timsort approach O(n), and for integers in a small range counting or radix sort run in linear time. Try different inputs in race mode to see the differences for yourself.

### What’s the difference between Lomuto and Hoare partitioning?

Lomuto uses the last element as the pivot and scans left to right, swapping smaller elements to the front — simple, but it does many swaps and degrades with lots of duplicates. Hoare moves two pointers towards each other and swaps only out-of-place pairs, typically doing less than half as many swaps and handling duplicates better. The Lomuto version here uses median-of-three so already-sorted input doesn’t degrade to O(n²).

### What is a stable sort?

A stable sort keeps equal elements in their original order. If you sort a list by name and then stably by score, people with the same score stay in name order. Merge, insertion, bubble, counting, radix and Timsort are stable; quicksort, heap sort, selection sort and Shell sort are not.

### Why do counting and radix sort make zero comparisons?

They don’t sort by comparing pairs: counting sort tallies how often each value occurs and writes them back in order, and radix sort distributes values into buckets digit by digit. That lets them sidestep the Ω(n log n) lower bound for comparison sorts and run in linear time when the value range or number of digits is small — paid for with extra memory, reads and writes, all shown in the counters.

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
