Tartifola wrote: > Hi, > how can I sort an array like > > array([[5, 2], > [1, 3]]) > > along the first column to obtain > > array([[1, 3], > [5, 2]]) > i.e. keeping track of the ordered couples? > > Thanks, > A
use a sort key: >>>from operators import getitem >>>a = [[5,2],[1,3]] >>>a [[5, 2], [1, 3]] >>>a.sort(key=lambda x:getitem(x,0)) >>>a [[1, 3], [5, 2]] -- http://mail.python.org/mailman/listinfo/python-list