基数排序
1 def radix(li): 2 # 1. 创建桶 3 max_mun = max(li) 4 buckets = [[] for _ in range(10)] 5 # 2.将数放到对应的桶里 6 it = 0 7 while 10 ** it <= max_mun: 8 for value in li: 9 b_id = (value//(10**it)) % 10 10 buckets[b_id].append(value) 11 li.clear() 12 for b in buckets: 13 li.extend(b) 14 b.clear() 15 it += 1 16 17 return li 18 19 li = [random.randint(0,10000) for i in range(100000)] 20 # print(li) 21 li = radix(li) 22 print(li) 23 print(len(li))