def unique_list(a_list, unique_func=None, replace=False):
    """Unique a list like object.

    - collection: list like object
    - unique_func: the filter functions to return a hashable sign for unique
    - replace: the following replace the above with the same sign

    Return the unique subcollection of collection.

    Example:
    data = [(1, 2), (2, 1), (2, 3), (1, 2)]
    unique_func = lambda x: tuple(sorted(x))
    unique(data)                              ->   [(1, 2), (2, 1), (2, 3)]
    unique(data, unique_func)                 ->   [(1, 2), (2, 3)]
    unique(data, unique_func, replace=True)   ->   [(2, 1), (2, 3)]
    """
    unique_func = unique_func or (lambda x: x)
    result = {}
    for item in a_list:
        hashable_sign = unique_func(item)
        if hashable_sign not in result or replace:
            result[hashable_sign] = item
    return list(result.values())