I have two arrays, a and b, as follows:
a = array([[19. , 0.84722222],
[49. , 0.86111111],
[54. , 0.86666667],
[42. , 0.9 ],
[ 7. , 0.91111111],
[46. , 0.99722222]])
b = array([[46. , 0.46944444],
[49. , 0.59722222],
[19. , 0.63611111],
[42. , 0.72777778],
[54. , 0.74722222],
[ 7. , 0.98888889]])
I would like to sort b so that its first column matches the first column of array a.
My output should be
b = array([[19. , 0.63611111],
[49. , 0.59722222],
[54. , 0.74722222],
[42. , 0.72777778],
[ 7. , 0.98888889]
[46. , 0.46944444]])
b[np.where(a[:,None] == b[None, :])[1]]