Welcome to the Monastery | |
PerlMonks |
Re^2: For Loops and Reversing outputby ikegami (Patriarch) |
on Dec 13, 2006 at 06:31 UTC ( [id://589496]=note: print w/replies, xml ) | Need Help?? |
reverse sort uses no more memory than sort. I've showed earlier in this thread that reverse sort is just as fast as sort. That's because an optimization causes reverse sort to sort the list in the reverse order rather than sorting the list then reversing it. That also means that reverse sort uses no more memory than sort. However, reversing an already sorted list takes more time and memory than not reversing it. Based on a reply the OP made, I suspect he will be receiving the list already sorted in the reverse of the desired order. If that's the case, then reversing the list then iterating over it would take time and memory, while iterating over the list from end to start could avoid using time and memory. Compare
against
In Section
Seekers of Perl Wisdom
|
|