I have a NumPy array of the form
a = [[[a1, a2, a3],
[a4, a5, a6],
[a7, a8, a9]],
[[b1, b2, b3],
[b4, b5, b6],
[b7, b8, b9]]]
and another array of the form
M = [[1, 0, 2],
[1, 2, 0]]
Is there an easy way to reorder the first array using the indices in the second one? So in the end the first one would become:
a = [[[a4, a5, a6],
[a1, a2, a3],
[a7, a8, a9]],
[[b4, b5, b6],
[b7, b8, b9],
[b1, b2, b3]]]