my @new_list = sort { ($a =~ /(\w+)(\w+)(\d+)/)[0] cmp ($b =~ /(\w+)(\w+)(\d+)/)[0] || ($a =~ /\[(\d+)/)[0] <=> ($b =~ /\[(\d+)/)[0] } @split_list;