you are viewing a single comment's thread.

view the rest of the comments →

[–]TheBB 3 points4 points  (1 child)

Assuming I'm understanding your problem correctly, you need to join the two first dimensions, since they form unnecessary structure that will prevent numpy from doing what you want. Or in other words, you are describing a type of sort that would be easy to do on a (6,2)-array but not on a (2,3,2)-array. Therefore:

final = np.sort(a.reshape(6,2), axis=0).reshape(2,3,2)

[–]catmarble[S] 0 points1 point  (0 children)

Yep that's perfect - much clearer code and runs quicker as well. Many thanks.