in reply to sorting and array by [2]
You might want to do a map-sort-map:for (sort third_field <INPUT>) { print "Record: $_"; } sub third_field { my $x = (split ' ', $a)[2]; my $y = (split ' ', $b)[2]; $x <=> $y; }
for (by_third_field <INPUT>) { print "Record: $_"; } sub by_third_field { map $_->[0], sort { $a->[3] <=> $b->[3] } map { [ $_, split ] } @_; }
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|