I have a 'list of arrays' and I order each of these arrays with argsort:
import numpy as np
arr = np.array([[4, 2, 5], [4, 3, 1], [1, 5, 7], [1, 5, 4]])
idxs = arr.argsort(axis=1)
idxs
>>> array([[1, 0, 2],
[2, 1, 0],
[0, 1, 2],
[0, 2, 1]])
For each of these 4 arrays I have 3x3 matrix that I save in a 'list of matrices':
arr2.shape
>>> (4, 3, 3)
I want to use idxs to sort the columns of each array. So for the first matrix I want to rearrange the columns like
m1 = arr2[0]
m1 = [:, [1, 0, 2]]
Just giving idxs in square brackets to arr2 won't work and even just trying to apply the idxs to the array they are coming from won't work:
arr[arr.argsort(arr, axis=1)].shape
>>> (4, 3, 3)