Bucket sort

Place numbers into four buckets and read them back in increasing order.

Each bucket covers its own range. Every value in the first bucket is smaller than every value in the second.

Watch what happens when 7 lands in the same bucket as 9. The values in each bucket are sorted before collection.

Distribution and collection take O(n). Comparison sorting inside the buckets takes up to O(n log n), with O(n) extra space.