perl> print map{ substr $_, 2 } sort map{ pack( 'n', $_ =~ m[(\d+)] ) . $_ } (@temp = qw[ A1 A11 A111 A2 A5 A50 ]); A1 A2 A5 A11 A50 A111