def radix_sort(collection):
RADIX = 10
position = 1
# get the maximum number
collection_max = max(collection)
while position < collection_max:
# declare and initialize buckets
buckets = [list() for _ in range(RADIX)]
# split collection between buckets
for i in collection:
tmp = int((i / position) % RADIX)
buckets[tmp].append(i)
# empty buckets into collection array
pos = 0
for b in range(RADIX):
bucket = buckets[b]
for i in bucket:
collection[pos] = i
pos += 1
# move to next
position *= RADIX
Runtime: