def sort_constraints(constraints):
    """
    Return a sorted sequence of unique GemConstraints.
    """
    constraints = sorted(constraints, key=lambda gc: (gc.version, gc.op))
    consts = []
    for gc in constraints:
        if gc in consts:
            continue
        consts.append(gc)
    return consts