1 | initial version |
A slightly more compact version of DSM's answer:
sage: L = [2,3,1,6,8,-3,9]
sage: L2 = sorted(L)
sage: P = Permutation([list(L).index(x)+1 for x in L2])
Testing the answer:
sage: P
[6, 3, 1, 2, 4, 5, 7]
sage: P.action(L)
[-3, 1, 2, 3, 6, 8, 9]
I wouldn't be surprised if this were slower to execute.