Comparisons

Counting Sort vs Radix Sort

Updated June 8, 2026 5 min read

Counting Sort vs Radix Sort compares two non-comparison sorts that both achieve near-linear time. They are closely related — Radix Sort actually uses Counting Sort internally — but they handle the range of values in fundamentally different ways.

The relationship

Counting Sort tallies every distinct value, needing O(k) memory for value range k. Radix Sort sidesteps the memory blow-up by sorting digit by digit, applying a stable Counting Sort on each digit so k stays tiny (just 10 for decimal digits).

When to use each

Use Counting Sort when the value range k is small (scores 0-100, ages). Use Radix Sort when values are large integers but have a fixed number of digits — it keeps memory low while still beating O(n log n). Both are stable and non-comparison.

Frequently asked questions

What is the difference between Counting Sort and Radix Sort? +
Counting Sort sorts by exact value and needs O(k) memory for the value range. Radix Sort sorts digit by digit using Counting Sort as a sub-routine, keeping memory low even for large value ranges.
Does Radix Sort use Counting Sort? +
Yes, LSD Radix Sort typically uses a stable Counting Sort for each digit position. The stability of each pass is what makes Radix Sort produce correct results.

See it in motion

Watch this algorithm and 9 others run step by step in our free interactive visualizer.

▶ Launch Visualiser

Related articles

← Back to all articles