U
Uri Guttman
AS> Just for fun, I tried this:
AS> my ( $ar, $br) = $order ? \ ( $a, $b) : \ ( $b, $a);
AS> my @sorted = sort { $$ar <=> $$br } @line;
AS> but in the sort block $$ar and $$br come up undefined. I don't quite
AS> understand that. It must be something about the way $a and $b are
AS> aliased to the list elements.
the sort block is passed $a and $b, they are not just set globally
before it is called. they are implicit params with fixed names and it
was done for speed.
and now it is time to plug Sort::Maker which would have made short
shrift of this whole thread.
uri
AS> my ( $ar, $br) = $order ? \ ( $a, $b) : \ ( $b, $a);
AS> my @sorted = sort { $$ar <=> $$br } @line;
AS> but in the sort block $$ar and $$br come up undefined. I don't quite
AS> understand that. It must be something about the way $a and $b are
AS> aliased to the list elements.
the sort block is passed $a and $b, they are not just set globally
before it is called. they are implicit params with fixed names and it
was done for speed.
and now it is time to plug Sort::Maker which would have made short
shrift of this whole thread.
uri