my @newarray = ($sub1,$sub2,$sub3); @newarray = sort { $a->[2] cmp $b->[2] } @newarray;