in reply to sort an array based on pattern

sort can take a compare function. Extract the digits and compare them.
@array = sort { my ($digits_from_a) = $a =~ /(\d+)\z/; my ($digits_from_b) = $b =~ /(\d+)\z/; $digits_from_b <=> $digits_from_a } @array;

Same, but a bit more terse:

@a = sort { ($b =~ /(\d+)\z/)[0] <=> ($a =~ /(\d+)\z/)[0] } @a;

The aforementioned Schwartzian Transform is an attempt to optimise this.