a1_2 a1_1 a10_10 a2_10 a2_1 a2_2 a10_1 a10_2 a1_10 #### a1_1 a1_2 a1_10 a2_1 a2_2 a2_10 a10_1 a10_2 a10_10 #### use strict; use warnings; open(INPUTFILE, "< ccc"); my @list = ; my $newlist=$list[0].$list[1].$list[2]; my @split_list = split(" " ,$newlist); my @new_list = sort { ($a =~ /(\d+)/)[0] <=> ($b =~ /(\d+)/)[0] || ($a =~ /(\w+)/)[0] cmp ($b =~ /(\w+)/)[0] } @split_list; print "@new_list\n";