MCPcopy Create free account
hub / github.com/BeeBombshell/Python-DSA / CountSort

Function CountSort

Sorting Algorithms/countSort.py:1–13  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

1def CountSort(arr):
2 res = [0]*len(arr)
3 count = [0]*10
4 for i in range(len(arr)):
5 count[arr[i]] = count[arr[i]] + 1
6 for i in range(1, 10):
7 count[i] = count[i] + count[i-1]
8 i = len(arr) - 1
9 while i >= 0:
10 res[count[arr[i]] - 1] = arr[i]
11 count[arr[i]] -= 1
12 i = i - 1
13 return res
14
15arr = input("Enter the list of numbers separated by commas: ")
16arr = [int(ele) for ele in arr.split(",")]

Callers 1

countSort.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected