From: George S. <geo...@gm...> - 2006-10-31 23:38:46
|
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 sorting. Thanks, George |