Repository where I mostly put random python scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

14 lines
463 B

def radix_sort(lista):
max_len = max([len(numero) for numero in lista])
padded = list([str(num).rjust(max_len, "0") for num in lista])
for pos in reversed(range(max_len)):
buckets = [list() for x in range(0, 10)]
for num in padded:
bucket = int(num[pos])
buckets[bucket] += [num]
padded = sum(buckets, [])
return padded
if __name__ == "__main__":
print(radix_sort(["13", "105", "10", "150"]))