Suppose you have two lists
B which are related by a permutation, and have no repeated elements.
Is there a simple and efficient way of finding the ordering
p which satisfies
The best I have is
p = First@FirstPosition[A,#]&/@B;
However, this seems inefficient as it neglects much of the structure of the problem. I imagined there might be a way of using
OrderingBy but I couldn't see a way to easily employ it, as it takes a function, rather than a canonical order, as its argument.