how to sort two dimensional array ??

R

Robert Somerville

Hi;
i am having trouble trying to sort the rows of a 2 dimensional array by
the values in the first column .. does anybody know how or have an
example of how to do this ??? while leaving the remain columns remain
relative to the leading column

from numpy import *

a=array( [ [4, 4, 3], [4, 5, 2], [3, 1, 1] ] )

i would like to generate the output (or get the output ...)

b = [ [3,1,1], [4,4,3], [4,5,2] ]



thanks;
bob
 
Joined
Jan 19, 2010
Messages
1
Reaction score
0
Code:
>>> a = array([[4,4,3],[4,5,3],[3,1,1]])
>>> sorted(a.tolist())
[[3, 1, 1], [4, 4, 3], [4, 5, 3]]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top