I understand that through Sort N-D numpy array by another 1-D array the use of fancy indexing, I can do the following c = a[:, :, b]
with b
defining the order to which I want to sort by column
>>> a = np.array([[[ 0, 1], [ 2, 3]],
[[ 4, 5], [ 6, 7]],
[[ 8, 9], [10, 11]]])
>>> b = np.array([1, 0])
>>> c = a[:, :, b]
>>> c
array([[[ 1, 0],
[ 3, 2]],
[[ 5, 4],
[ 7, 6]],
[[ 9, 8],
[11, 10]]])
Now I increase b
with 2 more inputs to b2
corresponding to how I want to sort each set of 2x2 in a
>>> b2 = np.array([[1, 0], [0, 1], [1, 0]])
>>> c2 = ?
>>> c2
array([[[ 1, 0],
[ 3, 2]],
[[ 4, 5],
[ 6, 7]],
[[ 9, 8],
[11, 10]]])
I have a larger set of inputs and I have a function that returns an array similar to 'b2' which provides me the info to which I should obtain. Hence may I know what should I filling into the c2 = ?
in order to get the desired result?