Like @ptrblck, I think taking a step back and noticing that no less than four kind people have been going out of their way trying to help might be useful. Keeping things friendly seems not only nice but also essential to your cause and the forums in general.
My impression is that the confusion is between the permutation mapping unordered to ordered (returned by argsort) and the inverse, mapping ordered to unordered.
In the 2d case, you can invert the permutation using scatter (in 1d, indexed assignment c[b] = torch.arange(...) is quicker and more obvious) if you need the inverse.
a = torch.randn(4,4)
b = a.argsort(dim=1)

c = torch.scatter(torch.zeros_like(b), 1, b, torch.arange(b.size(1))[None, :].expand_as(b))

# check that c is the inverse of b
print(b.gather(1, c))
# c, the inverse permutation of what argsort returns,  probably is what you are looking for
print(c)

# or you can get the sorted values and rearrange to match the original using the inverse permutation
print((a.gather(1, b)==a.sort(1).values).all().item())
print(((a.sort(1).values).gather(1, c)==a).all().item())

Best regards
Thomas