The Full Counting Sort

  • + 0 comments

    Using sort now fails some of the test cases.

    Here is my code

    def countSort(n, arr): # use n instead of len(arr)
    
        for l in arr:
            l[0] = int(l[0])  # convert first list item to integer
    				
        for i in range(n//2): # replace first half with hyphen
            arr[i][1] = "-"
    		
        # sort by number into empty list array
        output = [[] for _ in range(n)]
        for l in arr:
            output[l[0]].append(l[1])
            
        print(' '.join(j for i in output for j in i))