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";