代码:
#!/usr/bin/python
def bucketSort(a, n, buckets, m):
for j in range(m):
buckets[j] = 0
for i in range(n):
buckets[a[i]] += 1
i = 0
for j in range(m):
for k in range(buckets[j]):
a[i] = j
i += 1
有关Bucket sort算法的实现思想,请参考:http://pythontip.sinaapp.com/acm/post/4729