0

Python newbie.. this might be fairly straight-forward.. I tried looking through the other questions but no luck..

I have a nd array that looks like this:

pos=[[[567 341 741 450]]

[[803 513 839 538]]

[[733 446 881 539]]

[[656 411 800 512]]

[[513 308 534 324]]

[[579 356 602 373]]

[[549 335 576 355]]

[[558 335 608 366]]]

I want to do a sort based on the first column inside the array..Basically [[513 308 534 324]] should be the first element.. How do I go about it ?

4
  • 1
    sorted(pos, key=operator.itemgetter(0)) Commented Jun 2, 2017 at 22:13
  • @OzgurVatansever This question is about a numpy array, not a Python list. Commented Jun 2, 2017 at 22:21
  • @Gerry doesn't matter. Solutions both I proposed and the ones in the duplicate work for np.array types as well. Commented Jun 2, 2017 at 22:28
  • stackoverflow.com/questions/2828059/… Commented Jun 2, 2017 at 22:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.