In torch.sort or torch.argsort, I can specify descending to True or False to get sorted order I want.
How can I specify the sorting by a dynamic comparison order. For example, given following tensor to be sorted:
a = torch.tensor([[2, 1, 1, 2, 2, 2, 1], [3, 1, 1, 2, 2, 2, 1]])
compare = [torch.tensor([2, 1]), torch.tensor([2, 3, 1])]

I want a magic_argsort function give me the following result:
result = magic_argsort(a, compare)
# result is torch.tensor([[0, 3, 4, 5, 1, 2, 6], [3, 4, 5, 0, 1, 2, 6]])