计数排序:有确定的合适范围
class CountSort:
def countSort(self, arr):
if arr is None or len(arr)<2:
return
max_ = 0
for i in range(len(arr)):
max_ = max(max_, arr[i])
bucket = [0 for i in range(max_+1)]
for i in range(len(arr)):
bucket[arr[i]] += 1
i = 0
for j in range(len(bucket)):
while bucket[j] > 0:
arr[i] = j
i += 1
bucket[j] -= 1
基数排序:非负,十进制
基数排序的代码实现还是挺复杂的,这里先截图