def bucket_sort(arr): bucket = [0]*(max(arr)-min(arr)+1) for i in range(len(arr)): bucket[arr[i]-min(arr)] += 1 print(bucket) res = [] for i in range(len(bucket)): if bucket[i] != 0: res += [i+min(arr)]*bucket[i] return res
原文:https://www.cnblogs.com/director/p/12770369.html