in reply to Sort multidimensional array by third item
Note that instead of this:
my @line_array = <FILE>; shift(@line_array); pop(@line_array);
You can use an array slice:
@line_array = @line_array[1..-2]; #I guess you can't (see following posts)Another solution:
... ... my @lines = (<$INFILE>)[1..-2]; my @unsorted = map [split], @lines; my @sorted = sort {$a->[2] <=> $b->[2]} @unsorted; for my $arr_ref (@sorted) { print "@$arr_ref\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort multidimensional array by third item
by kennethk (Abbot) on Nov 12, 2010 at 22:42 UTC | |
by 7stud (Deacon) on Nov 12, 2010 at 22:55 UTC | |
by kennethk (Abbot) on Nov 12, 2010 at 22:59 UTC | |
|