Skip to content

Instantly share code, notes, and snippets.

@hvuhsg
Created March 2, 2022 16:25
Show Gist options
  • Save hvuhsg/a0eea706ad46a311f50194d829c258aa to your computer and use it in GitHub Desktop.
Save hvuhsg/a0eea706ad46a311f50194d829c258aa to your computer and use it in GitHub Desktop.
numbers = [5, 8, 6, 3, 9, 9, 2, 4, 7, 7, 6]
def sort(arr):
bucket = [0] * 100
for number in arr:
bucket[number] += 1
sorted_arr = []
for i, num in enumerate(bucket):
sorted_arr.extend([i] * num)
return sorted_arr
print(sort(numbers)) # -> [2, 3, 4, 5, 6, 6, 7, 7, 8, 9, 9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment