On Tue, Jan 19, 2010 at 9:00 AM, Robert Somerville <span dir="ltr"><<a href="mailto:rsomerville@sjgeophysics.com">rsomerville@sjgeophysics.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi;<br></blockquote><div><br></div><div>Hi, why did you post this three times?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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<br>


<br>
from numpy import *<br>
<br>
a=array( [ [4, 4, 3], [4, 5, 2],  [3, 1, 1] ] )<br>
<br>
i would like to generate the output (or get the output ...)<br>
<br>
b = [ [3,1,1], [4,4,3], [4,5,2] ]<br></blockquote><div><br></div><div>I don't use numpy, so this may or may not work. But for a regular python list-of-lists (2 dimensional array), you simply do:</div><div><br></div><div>

a.sort(key=lambda x: x[0])</div><div><br></div><div>--S</div></div>