def imp_compare(sample_list, first, last):
    """
    This function aims to find tuples with each unique first element.For equal first element tuples,
    find the one with largest last element.
    
    Parameters
    ----------
    sample_list : list,
      This parameter represents the a list of several tuples.
    first : integer,
      This parameter represents the first index of each tuple
    last : integer,
      This parameter represents the last index of each tuple
    
    Returns
    -------
    res : list,
      A list of finding tuples
    
    """
    # a vector to contain unique first value among all tuples
    op = []
    for m in range(len(sample_list)):
        li = [sample_list[m]]
        # the range is lower
        for n in range(m,len(sample_list)):
            # it is not necessary to compare whether the last element is identical,
            # because when last elements are equal, 'sorted ' function will choose the 
            # one with smaller index. Then because in loop m, list 'li' appends every 
            # element during the whole iteration. So no element will be ignored in this case.
            if (sample_list[m][first] == sample_list[n][first]):
                li.append(sample_list[n])
        op.append(sorted(li, key = lambda dd: dd[2], reverse = True)[0])
    res = list(set(op))
    return res