@pretty=sort { my @a = $a =~ /(\D+)(\d+)/; my @b = $b =~ /(\D+)(\d+)/; $a[0] cmp $b[0] || $a[1] <=> $b[1] } @not_so_pretty;