I realize this isn't the standard counting sort as stated in CLRS, but what does my simplified version lack that the standard counting sort has? I realize mine only sorts positive integers, but that should be pretty easy to tweak (by using maps).
def count_sort(array):
maximum = max(array)
minimum = min(0, min(array))
count_array = [0]*(maximum-minimum+1)
for val in array:
count_array[val] += 1
sorted_array = []
for i in range(minimum, maximum+1):
if count_array[i] > 0:
for j in range(0, count_array[i]):
sorted_array.append(i)
return sorted_array
array = [3,2,-1,1,5,0,10,18,25,25]
print array
print count_sort(array)
Edit: The reason why I thought this wasn't the standard counting sort was because the algorithm covered in the MIT OpenCourseware lecture seemed slightly more involved (http://youtu.be/0VqawRl3Xzs?t=34m54s).