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


in reply to Sorting an array of lines

Take a look at Complex Sorting, it's an excellent explaination of what you need.
#!/apps/bin/perl -w my (@array, @sorted) =(); while (<>) { chomp; push (@array, $_); } @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map { my ($sortvalue) = /(\d+)$/; [$_,$sortvalue]; } @array; print "@sorted\n";