My understanding is that it would sort just the field, not the entire row.
Not quite. Look at this small example:
use strict; use warnings; use Data::Dumper; my @items = ( [0, 4, 2], [2, 5, 8], [-5, 0, -3], [3, 4, 0], [1, 4, 8], ); my @sorted = sort { $a->[1] <=> $b->[1] } @items; print Dumper \@sorted; __END__ $VAR1 = [ [ -5, 0, -3 ], [ 0, 4, 2 ], [ 3, 4, 0 ], [ 1, 4, 8 ], [ 2, 5, 8 ] ];
(I tidied up the output a bit to include less line breaks).
You can see that the array is sorted by the second column, but the result is a list of array references, just like the input.
sort is very powerful, you only have to know how to use it ;-)
In reply to Re^3: Need help making my Merge Sort implementation stable
by moritz
in thread Need help making my Merge Sort implementation stable
by taffer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |