@origarray=('0 1 2','0 0 0','-3 -2 -1','10 11 12'); @sortedarray= map{$_->[0]} sort{$a->[1] <=> $b->[1]} map{ my @cols=split(/\s+/); my $sum=$cols[0]+$cols[1]+$cols[2]; [$_,$sum]; } @origarray; foreach(@sortedarray){ print "$_\n"; }