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