my @a2; while my $elem (@array) { my @fields = split(/_/, $elem, 3); push @a2, \@fields; } my @a3 = sort { $b->[2] <=> $a->[2]} @a2;