in reply to Re^3: Sorting on different fields
in thread Sorting on different fields
my @data while (my $line = <TEMPFILE>) { my @elements = $line; push @data, \@elements; # need to store as ref } @data = sort { $$a[2] cmp $$b[2] or $$a[1] <=> $$b[1] } @data or die + "can't sort"; foreach my $item (@data) { print TEMPFILE @$item; print TEMPFILE "\n"; }
Edit by tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Sorting on different fields
by Aristotle (Chancellor) on Jul 23, 2002 at 14:32 UTC |