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


in reply to Sort array

You can use a regex to extract the numbers:
#!/usr/bin/perl use strict; use warnings; use feature "say"; my @unsorted_array = qw( page1.html page11.html page2.html page3.html +); say for sort { ($a =~ /([0-9]+)/)[0] <=> ($b =~ /([0-9]+)/)[0] } @unsorted_array;
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]