Reading records from file and sorting

George Sakkis george.sakkis at
Tue Oct 31 17:38:43 CST 2006

Is there a more elegant and/or faster way to read some records from a
file and then sort them by different fields ? What I have now is too
specific and error-prone in general:

import numpy as N
records = N.fromfile(a_file, dtype=N.dtype('i2,i4'))
records_by_f0 = records.take(records.getfield('i2').argsort())
records_by_f1 = records.take(records.getfield('i4',2).argsort())

If there's a better way, I'd like to see it; bonus points for in-place


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

More information about the Numpy-discussion mailing list