in reply to sort an array based on pattern

If the array to be sorted is very large, a Guttman Rosler Transform (GRT) may be advantageous (see A Fresh Look at Efficient Perl Sorting and Understanding transformation sorts (ST, GRT), the details):

>perl -wMstrict -le "my @ra = qw(abc1 abc32 abc64 abc8 abc16); ;; my $wide = 15; my @sorted = map unpack(qq{x$wide a*}), reverse sort map sprintf('%0*d%s', $wide, m{ (\d+) \z }xms, $_), @ra ; ;; print qq{@sorted}; " abc64 abc32 abc16 abc8 abc1

See also Sort::Maker.