Avoid FindIndex function by using the inverse permutation.
Avoid FindIndex function by using the inverse permutation.

Let p be a permutation. FindIndex(p, x) should return y where x = p[y].
This is equivalent to p^-1[x] = p^-1[p[y]] = y, so y = p^-1[x].
