import random def radix_sort(li): max_value = max(li) it = 0 while 10 ** it <= max_value: buckets = [[]for _ in range(10)] for x in li: digit = (x // 10 ** it) % 10 buckets[digit].append(x) li.clear() for b in buckets: li.extend(b) it += 1 def main(): li = list(range(100)) random.shuffle(li) print(li) radix_sort(li) print(li) if __name__ == '__main__': main()