The returned values from sort() are differentiable if that is what you are asking. For
input2, indices = input1.sort(dim=1, descending=True)

The gradient of input1 will be the re-ordered gradient of input2. For example,
input1 = torch.tensor([1., 3., 2.], requires_grad=True)
input2, _ = input1.sort(descending=True)  # 3, 2, 1
input2.backward(torch.tensor([0.3, -0.2, 0.01]))
print(input1.grad)  # 0.01, 0.3, -0.2