Hi

Lets say I have tensor x

x = torch.tensor([

[1, 2, 3, 4, 3, 3, 4],

[1, 6, 3, 5, 3, 5, 4]

], dtype=torch.long)

and tensor y which are the associated scores

torch.tensor([

[1, 1, 1, 1, 2, 1, 1],

[1, 1, 1, 1, 2, 2, 1]

], dtype=torch.long)

I want the output such that each row of x is sorted and the duplicates are sorted based upon scores. So the final output will be

x = torch.tensor([

[1, 2, **3**, 3, 3, 4, 4],

[1, 3, 3, 4, 5, 5, 6]

], dtype=torch.long)

The bold 3 correspond to the score 2 in tensor y. Is there any way I can do it efficiently by just using the PyTorch functions?

Thank you