I have a tensor like this [[1,2],[-1,2],[1.3,3],[-2,5]] i have to sort this tensor with respect to the first value(ie, 1,-1,1.3,-2) while not changing the other value in the pair. The result should looks like this [[-2.5],[-1,2],[1,2],[1.3,3]].
You could use something like
t = torch.tensor([[1,2],[-1,2],[1.3,3],[-2,5]])
idx = t[:,0].argsort()
t_sorted = t[idx]
t_sorted
Best regards
Thomas