def argsort(seq):
    """
    >>> seq=[1,3,0,4,2]
    >>> index=argsort(seq)
    [2, 0, 4, 1, 3]
    Given seq and the index, you can construct the sorted seq:
    >>> sorted_seq=[seq[x] for x in index]
    >>> assert sorted_seq == sorted(seq)
    Given the sorted seq and the index, you can reconstruct seq:
    >>> assert [sorted_seq[x] for x in argsort(index)] == seq
    """
return sorted(list(range(len(seq))), key=seq.__getitem__)

def f(seq):
    idx = argsort(seq)
return argsort(idx)
print(f([3, 1, 2]))
print(f([3, 1, 2, 2, 3]))
Given a "jumbled" list L, get a list where each element is the index of the corresponding element of L, if L was sorted