my @pretty = map {s/(?<=\D)0+//; $_} sort map {chomp; do {no warnings; sprintf "%s%05d", /(\D*)(\d*)/}} @not_so_pretty;