#!perl -wl # this will sort numerically by the first number found; and alphabetically # if necessary # and of course it's schwartzian-transform-ized, because hey why not use strict; my @array = qw(POST100 XX1Z XX1A XX2B POST5 POST10 POST1 BOB1); foreach ( map { $_->[0] } sort { $b->[1] <=> $a->[1] || $a->[0] cmp $b->[0] } map { [ $_ , do { /(\d+)/; $1 } ] } @array ) { print; }