in reply to sorting CSV files
Am I the only one this reeks of homework to? In general, people are happy to help if you at least start with some code and specific questions about it (and why it's not working).
Maybe you can turn in the following one liner (for Windows)...?
... where the only argument (before the input file) specifies on which column to sort and in which direction (negative column value for descending sort, positive for ascending).C:\temp>perl -F, -ane "BEGIN{$c = shift} push @a, [@F]; END{print join +(',' => @$_) for sort {($a->[abs($c)-1] cmp $b->[abs($c)-1]) * $c} (@ +a)};" -- -3 grades.csv Jim,72,IL Rob,63,FL Mike,67,CA Chan,32,AZ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting CSV files
by Anonymous Monk on Apr 28, 2008 at 07:19 UTC | |
by crashtest (Curate) on May 01, 2008 at 18:16 UTC | |
by Anonymous Monk on May 06, 2008 at 07:57 UTC |