Solved by KFrank in post #3 
              
              
                Hi Damien (and Alex)! 

In my mind, the cleanest approach is to take the argsort of the 
permutation: 
import torch
torch.__version__

t = torch.LongTensor ([1, 5, 3, 4])
perm = torch.sort (t, descending = True)[1]
perm
inverse = torch.sort (perm)[1]   # invert permutation
inverse
perm[inverse]    #…