http://www.perlmonks.org?node_id=26213


in reply to Re: text sorting question
in thread text sorting question, kinda

Here is a slightly modified version of the above version, but using an '||' in the 'sort' block to make sure the lines are in the proper order.
my @sorted = map { $_->[2] } sort{ $b->[0] <=> $a->[0] || $a->[1] <=> $b->[1] } map { [ (split '\s+', $file[$_])[2] eq 'blahblah', $_, $f +ile[$_] ] } 0 .. $#file;