Question: Sorting a list + obtaining sign of permutation

Hello,

 

I am working with wedge products, and I came up with this question: how can I efficiently sort a list of indices, and obtain the sign of the associated permutation?

So for [4,3] I would like to obtain [3,4]-

for [1,4,2] I would want to obtain [1,2,4] -

for [2,1,4,3] I would want to obtain [1,2,3,4]+

I know I can do sort([4,3]) but what about the sign of that permutation?

 

Thanks!

Please Wait...