def sort_rat(name_list: list, ratings: list, reverse: bool = True):
    """
    Sort ratings associated with names. The sort is stable.

    :param name_list: The list of names to be associated with the ratings respectively
    :param ratings: The list of ratings to sort
    :param reverse: Descending by default. False means ascending.
    :return: The sorted list of names and their ratings and rankings
    """
    if len(name_list) != len(ratings):
        raise ValueError("# of names %d does not equal to # of ratings %d" % (len(name_list), len(ratings)))
    result = list()
    for i, name in enumerate(name_list):
        result.append((name, ratings[i]))

    def compare(name_rat):
        return name_rat[1]
    result.sort(key=compare, reverse=reverse)
    return [(r[0], r[1], i + 1) for i, r in enumerate(result)]