As a challenge, I\'ve given myself this problem:
Given 2 lists, A, and B, where B is a shuffled version of A, the idea is to figure out the shuffled indices.
We can make use of np.searchsorted with its optional sorter
argument -
sidx = np.argsort(B)
out = sidx[np.searchsorted(B,A, sorter=sidx)]
Sample run -
In [19]: A = [10, 40, 30, 2, 40]
...: B = [30, 2, 10, 40]
...:
In [20]: sidx = np.argsort(B)
In [21]: sidx[np.searchsorted(B,A, sorter=sidx)]
Out[21]: array([2, 3, 0, 1, 3])