The Full Counting Sort

  • + 0 comments
    1. create empty array of 100 arrays
    2. add elements acc to index mentioned
    3. remove empty elements
    4. convert to string

    def countSort(arr):

    arr_sort = [[] for _ in range(100)]
    arr_len = len(arr)
    for j in range(arr_len):
        f = int(arr[j][0])
        s = arr[j][1]
        if j < arr_len // 2:
            arr_sort[f].append('-')
        else:
            arr_sort[f].append(s)
    
    res = [y for x in arr_sort for y in x]
    print(" ".join(res))