in reply to Re: Sort lines in a file
in thread Sort lines in a file
I don't know that you can say that in general. Some sort algorithms have worst case timings when sorting a pre-sorted (or nearly pre-sorted) list.
That being said, however, Perl may take that into account.
I do not, however, without benchmark data, buy that running sort() inside of a loop is faster than running sort outside of the loop.
Does anyone have a benchmark framework that can test inside and outside sorts with input data that is sorted, reverse-sorted, nearly sorted, and random?
--MidLifeXis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sort lines in a file
by blackdragoen (Novice) on Feb 15, 2008 at 04:33 UTC |