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