Find permutation of an array such that it is equal to another array

B[sortperm(B)[invperm(sortperm(A))]]

i.e. sort array B and then follow backwords the sorting permutation of array A, to make B into A.

2 Likes