my @foo = qw/ a3 b2 r4 s1 /; print for STsort( sub { /(\d+)$/ }, sub { $_[0][1] <=> $_[1][1] }, @foo ); __END__ s1 b2 a3 r4