in reply to how to do effective sort in perl
If it's an efficient sort algorithm you're after, you should note that "In 5.7, the quicksort implementation was replaced with a stable mergesort algorithm whose worst-case behavior is O(NlogN)." (perldoc). According to Numerical Recipes, "For the basic task of sorting N elements, the best algorithms require on the order of several times N log2 N operations." That means that mergesort is just about as efficient as you can get.
Incidentally, Numerical Recipes is an astonishingly good book. Knuth may be the definitive reference, and nag may have many algorithms fine-tuned to specific cases, but NR is exceptionally good value for money. You can even download free source code in FORTRAN or C. If you're new to Perl, I'd see the lack of a Perl version as a good thing. I think it's a useful exercise in learning a language to try translating into it.
Update: Of course, all of this is overkill for the number of items likely to be found in any sensible directory!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to do effective sort in perl
by graff (Chancellor) on May 04, 2006 at 02:35 UTC | |
by Polonius (Friar) on May 04, 2006 at 14:57 UTC | |
by MidLifeXis (Monsignor) on May 04, 2006 at 17:37 UTC |