def select_extinction(extinction, way="min"):
    """
    For each star sort and select only one extinction value.

    Parameters
    ----------
    extinction : list of tuples
        A list returned by the extinction function.
    way : string
        A method to select only one extinction value.
        - "min"
        - "max"

        Default value "min".
    """
    stars_indexes = set([star[0] for star in extinction])
    extinction_values = []

    for star_id in stars_indexes:
        star_extinction = []

        for ext in extinction:
            if star_id == ext[0]:
                star_extinction += [ext]

        if way == "min":
            extinction_values += [min(star_extinction, key=lambda x: x[-1])]
        else:
            extinction_values += [max(star_extinction, key=lambda x: x[-1])]

    return extinction_values