[SciPy-user] Sort by first n columns in an array

Dharhas Pothina Dharhas.Pothina@twdb.state.tx...
Thu Jul 9 10:21:06 CDT 2009

>>> Neil Crighton <neilcrighton@gmail.com> 7/8/2009 6:14 PM >>>
>Something like this should work:
>data = np.genfromtxt(filename, dtype=None, usecols=(0,1,2),
>                    names='year,month,day')
>data.sort(order=['year', 'month', 'day'])

That works if I know the number of columns prior to reading the file. In this case I'm reading a file with an unknown number of columns. I know that the first six columns are the date fields.


- dharhas

More information about the SciPy-user mailing list