in reply to Re^2: Sort command equivalent in perl
in thread Sort command equivalent in perl
You're right. it wouldn't work for files greater than memory.
I thought it might for a while because of the in-place sort optimisation that came in somewhere in 5.8.x, that means that:
@ar = sort @r;
gets converted to sort \@ar; and sorts in place rather then copies the array to the stack and back.
But looking at the code, it doesn't work for tied arrays:
/* optimiser converts "@a = sort @a" to "sort \@a"; * in case of tied @a, pessimise: push (@a) onto stack, then assig +n * result back to @a at the end of this function */
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sort command equivalent in perl
by davido (Cardinal) on Dec 16, 2011 at 17:25 UTC |