def counting_sort(num_arr, cur, base):
    """
    Modified counting sort

    :param num_arr: array of Number-s
    :param cur: current index of numeral
    :param base: base of radix sort
    :return: sorted array of Number-s
    """

    count_arr = [0 for _ in range(base + 1)]
    res = [None] * len(num_arr)
    for el in num_arr:
        count_arr[el[cur]] += 1
    for i in range(1, base + 1):
        count_arr[i] += count_arr[i - 1]
    for i in range(len(num_arr) - 1, -1, -1):
        res[count_arr[num_arr[i][cur]] - 1] = num_arr[i]
        count_arr[num_arr[i][cur]] -= 1
    return res