Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: RFC:A brief tutorial on Perl's native sorting facilities.

by jimbojones (Friar)
on Feb 06, 2007 at 14:48 UTC ( #598549=note: print w/ replies, xml ) Need Help??


in reply to RFC:A brief tutorial on Perl's native sorting facilities.

Hi

Liked the tutorial. One additional thing that you might want to reference at this point
How sort actually works internally doesn't really matter. That it is about as fast as you are likely to get; that it is built-in to language so always available; and that it understands Perl internals; does.
is that the internals of the Perl sort changed from quicksort to a mergesort between 5.6 and 5.8.

Although the main change is probably to defend against worst-case O(N**2) behaviour, the user can be bitten by this "feature"

From CPAN Sort.pm
A stable sort means that for records that compare equal, the original input ordering is preserved. Mergesort is stable, quicksort is not.
This means if you use 5.6, and your comparator returns 0 for 2 items that are in fact different, the input order and the output order of those items may change. This behaviour burned me recently; others may want to know about it.


Comment on Re: RFC:A brief tutorial on Perl's native sorting facilities.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://598549]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-07-26 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls