Counting, Bucket & Radix Sort
In short: every sort in section 3 decided order by comparing two
items. Counting sort never compares anything — it counts how many times each
value occurs, turns those counts into positions with a running total, then
places each item straight into its final slot. That makes it O(n + k),
where k is the range of values, beating any comparison sort's O(n log n)
floor. But it only works on a small range of non-negative integers. Radix
sort lifts that limit by running a stable counting sort once per digit,
from the ones place up, so it can sort numbers of any size in O(d·n), where
d is the digit count. Both are stable — and they have to be, or radix
sort's later digit-passes would undo the sorting the earlier passes did.

Sort record IDs without comparing them
Quarry ingests a batch of small non-negative record IDs overnight and needs them sorted before the morning read. Counting sort never asks "is this one bigger than that one" — it only counts:
The prefix-summed counts array turns "how many 2s are there" into "how many
items belong at or before a 2" — exactly the final index each item needs,
counting from the back so that the last equal item lands in the
highest open slot, leaving earlier arrivals the lower ones. Watch the
output array fill in, one placement at a time:
Scanning the input backward and placing straight into the final slot is what keeps equal values in their original order.
The last input value is 2 (index 5). Its running count says "one belongs at position 3". 6 cells. At index 3.