Hi,

I’m looking for a function to sort the value of a 2D tensor by a given order.

For example, A is a 2D tensor ([1, 0, 2, 2, 1], [0, 2, 1, 2, 0]), and I want to sort A following an order tensor B as ([3, 2, 4, 1, 0], [2, 1, 4, 3, 3]). So the sorted A should be ([2, 2, 1, 0, 1], [1, 2, 0, 2, 2]). There can be repeating elements in the same row of B and each row of A is sorted by the order in corresponding row of B.

Is there any function I can directly apply to get the sorted A?

Any suggestion is appreciated!