you can try this,also
def sort_tensor(X, dim=-1):
  d1, d2 = X.size()
  ten, ind=torch.sort(X, dim=dim)
  if dim == -1:
    return X[torch.arange(d1).unsqueeze(1).repeat((1, d2)), ind]
  elif dim == 0:
    return X[ind, torch.arange(d2)]
  else:
    raise IndexError("wrong dim parameter")

output:
t = torch.tensor([[23, 45, 66, 100], 
                [90, 56, 8,132],
                [34, 90, 88, 200],
                [250, 15, 90, 5]])

sort_tensor(t, dim=-1)
output:
tensor([[ 23,  45,  66, 100],
        [  8,  56,  90, 132],
        [ 34,  88,  90, 200],
        [  5,  15,  90, 250]])

sort_tensor(t, dim=-0)
output:
tensor([[ 23,  15,   8,   5],
        [ 34,  45,  66, 100],
        [ 90,  56,  88, 132],
        [250,  90,  90, 200]])