let's assume I have an array of form
a = [
[ [12, 4, 2, 5] , [10, 12, 4, 2], [2, 2, 10, 2], [7, 10, 3 ,2] ],
[ [13, 23, 4, 5] , [10, 12, 4, 2], [2, 2, 12, 1], [7, 10, 3 ,2] ],
[ [4, 4, 2, 5] , [10, 12, 4, 2], [2, 2, 3, 2], [7, 10, 3 ,2] ],
]
I want to sort by the first column of each element, so the first entry of a would read:
[ [2, 2, 10, 2], [7, 10, 3 ,2], [10, 12, 4, 2], [12, 4, 2, 5] ]
I've found a solution that looks like a[a[:,1].argsort()] and tried a for loop over the first index like:
for i in range(0,4):
a[i,...] = a[a[i,0,:].argsort()]
or
for i in range(0,4):
a[i,...] = a[i, a[i,0,:].argsort()]
This doesn't work tho. I really can't get my head around this problem.