Radix sort is one of the linear sorting algorithms for integers. It functions by sorting the input numbers on each digit, for each of the digits in the numbers. However, the process adopted by this sort method is somewhat counterintuitive, in the sense that the numbers are sorted on the least-significant digit first, followed by the second-least significant digit and so on till the most significant digit.
Radix Sort Is the One of the Fastest Sorting algorithm doing it in order
O(k*N)
def radixsort():
num=[]
for i in range(10):
num+=[[]]
nums = [int(j) for j in raw_input().split()]
maxn = len(str(max(nums)))
sortn = nums[:]
for x in range(1,maxn+1):
i=-1*x
for j in sortn:
z = str(j)
if(len(z)<x):
num[0]+=[j]
else:
num[int(z[i])]+=[j]
sortn=[]
for k in range(10):
sortn+=num[k][:]
num[k]=[]
print sortn
radixsort()
Radix Sort Is the One of the Fastest Sorting algorithm doing it in order
O(k*N)
def radixsort():
num=[]
for i in range(10):
num+=[[]]
nums = [int(j) for j in raw_input().split()]
maxn = len(str(max(nums)))
sortn = nums[:]
for x in range(1,maxn+1):
i=-1*x
for j in sortn:
z = str(j)
if(len(z)<x):
num[0]+=[j]
else:
num[int(z[i])]+=[j]
sortn=[]
for k in range(10):
sortn+=num[k][:]
num[k]=[]
print sortn
radixsort()