Perl – Sorting multi-diminsional arrays

To numerically sort @myarray by the second column do this:

@myarray = sort { $a->[1] <=> $b->[1] } @myarray;

Here is an alpha sort of @myarray on the third column:

@myarray = sort { $a->[2] cmp $b->[2] } @myarray;
blog comments powered by Disqus