radix sort can be apply to data that can be sorted lexicographically, be they integers, words, punch cards, playing cards, or the mail. It avoids comparison by make and distribute components into buckets according to their radix. radix sorting algorithms get into common purpose as a manner to sort punched cards as early as 1923.The first memory-efficient computer algorithm was developed in 1954 at MIT by Harold H. Seward. The linear scan is closely associated to Seward's other algorithm — counting sort. computerize radix kinds had previously been dismissed as impractical because of the perceived need for variable allocation of buckets of unknown size.
def radix_sort(lst): RADIX = 10 placement = 1 # get the maximum number max_digit = max(lst) while placement < max_digit: # declare and initialize buckets buckets = [list() for _ in range(RADIX)] # split lst between lists for i in lst: tmp = int((i / placement) % RADIX) buckets[tmp].append(i) # empty lists into lst array a = 0 for b in range(RADIX): buck = buckets[b] for i in buck: lst[a] = i a += 1 # move to next placement *= RADIX