def __new__(cls, p, distinct=True):
    """ Initializes a mpermutation object, internal indexing starts at zero. """
    if isinstance(p, cls):
        return tuple.__new__(cls, p)
    elif isinstance(p, tuple):
        entries = list(p)[:]
    elif isinstance(p, list):
        entries = list(set(p))
    if distinct:
        assert len(entries) == len(p)
    entries.sort()
    standardization = map(lambda e: entries.index(e), p)
    return tuple.__new__(cls, standardization)
