Skip to content

Instantly share code, notes, and snippets.

@tuvo1106
Created July 4, 2019 16:50
Show Gist options
  • Save tuvo1106/7dba7f86367b6832b08a548fc7a11435 to your computer and use it in GitHub Desktop.
Save tuvo1106/7dba7f86367b6832b08a548fc7a11435 to your computer and use it in GitHub Desktop.
def countsort(l:list):
arr = l[::]
k = 0
new_list = (max(arr) + 1) * [0]
for j in arr:
new_list[j] += 1
for i in range(max(arr) + 1):
if i != 0:
new_list[i] += new_list[i - 1]
while new_list[i] != k:
arr[k] = i;
k += 1
return arr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment