Search notes:

torch.Tensor: sort() / argsort()

import torch

t = torch.tensor ([ [2,3,1] , [5,4,6] ])

s = torch.sort()

print(s.values)
#
# tensor([[1, 2, 3],
#         [4, 5, 6]])

print(s.indices)
#
# tensor([[2, 0, 1],
#        [1, 0, 2]])

print(t.argsort())
#
# tensor([[2, 0, 1],
#        [1, 0, 2]])

See also

torch.Tensor

Index