Counting Sort 3

  • + 0 comments
    def counterForSortThree(arr):
        arr_counter = [0] * 100
        for j in arr:
            extracted_int = j.split()[0]
            arr_counter[int(extracted_int)] += 1
        return arr_counter
    
    
    def countingSort3(arr):
        new_arr = counterForSortThree(arr)
        counter_result = 0
        result = []
        for i in range(0, len(new_arr)):
            while new_arr[i] > 0:
                counter_result += 1
                new_arr[i] -= 1
            result.append(counter_result)
    
        print(*result)
    
    if __name__ == '__main__':
        n = int(input().strip())
        arr = []
        for i in range(n):
            arr.append(input())
        countingSort3(arr)