# Radix Sort visualised: digit by digit into buckets

> Interactive Radix Sort (LSD): stable Counting Sort per digit, base 10 with 10 buckets. Linear O(d · n) for integer keys with a fixed number of digits.

Address: https://marckimmel.de/en/informatik/sortieralgorithmen/radix-sort
Deutsche Fassung: https://marckimmel.de/informatik/sortieralgorithmen/radix-sort.md

Sorts digit by digit into buckets, without any direct value comparisons.

Radix Sort sorts numbers digit by digit, never comparing values directly. The LSD variant (Least Significant Digit) starts at the least significant digit: it distributes elements into 10 buckets (digits 0–9 in base 10) and gathers them back in bucket order. This step repeats for each digit until the most significant one. Because the per-digit distribution is stable, every iteration preserves the order of equal keys, and after the last digit the array is correctly sorted. Runtime is O(d · (n + b)) where d is the digit count of the largest element and b is the base (10 here); for integers with known magnitude d is constant, so Radix Sort runs effectively linearly. Memory is O(n + b) for the buckets and the algorithm is stable. Applicable only to nonnegative integers or data with a fixed digit structure.

Sorting large amounts of integer keys with bounded digit count, such as phone numbers, postal codes or IPv4 addresses. Also found in database engines and in string sorting as the MSD variant.

## Related

- [Sorting Algorithms](https://marckimmel.de/en/informatik/sortieralgorithmen.md)
