0
我使用这个代码在Python与基数排序列表蟒蛇功能基数排序使用
def radix(self, a):
len_a = len(a)
modulus = 10
div = 1
while True:
'''DECLARATION OF BUCKETS'''
new_list = [[], [], [], [], [], [], [], [], [], []]
for value in a:
least_digit = value % modulus
least_digit /= div
new_list[least_digit].append(value)
modulus = modulus * 10
div = div * 10
if len(new_list[0]) == len_a:
'''RETURN THE LIST WHEN SORTED'''
return new_list[0]
a = []
rd_list_append = a.append
for x in new_list:
for y in x:
rd_list_append(y)
我无法了解这些行做
a = []
rd_list_append = a.append
for x in new_list:
for y in x:
rd_list_append(y)
我知道该怎么for循环将工作,但什么是 rd_list_append(y) 请帮助我。我是python的新手。
你从哪里得到这段代码? – Wajahat 2014-10-17 06:21:41