Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

sorting agorithm

by abubacker (Pilgrim)
on Aug 13, 2009 at 07:52 UTC ( [id://788141]=perlquestion: print w/replies, xml ) Need Help??

abubacker has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: sorting agorithm
by busunsl (Vicar) on Aug 13, 2009 at 08:06 UTC
Re: sorting agorithm
by Anonymous Monk on Aug 13, 2009 at 08:03 UTC
    perldoc -f sort | grep algo
    Perl 5.6 and earlier used a quicksort algorithm to implement sort. That algorithm was not stable, and *could* go quadratic. implementation was replaced with a stable mergesort algorithm sort. Its rather blunt control of the underlying algorithm may # guarantee stability, regardless of algorithm
      And now including the lines that do not contain the word "algorithm":
                     Perl 5.6 and earlier used a quicksort algorithm to implement
                     sort.  That algorithm was not stable, and could go quadratic.
                     (A stable sort preserves the input order of elements that
                     compare equal.  Although quicksort’s run time is O(NlogN) when
                     averaged over all arrays of length N, the time can be O(N**2),
                     quadratic behavior, for some inputs.)  In 5.7, the quicksort
                     implementation was replaced with a stable mergesort algorithm
                     whose worst-case behavior is O(NlogN).  But benchmarks
                     indicated that for some inputs, on some platforms, the original
                     quicksort was faster.  5.8 has a sort pragma for limited
                     control of the sort.  Its rather blunt control of the
                     underlying algorithm may not persist into future Perls, but the
                     ability to characterize the input or output in implementation
                     independent ways quite probably will.  See sort.
      
        I see you used
        perldoc -f sort | grep -C5 algo
        :)
Re: sorting agorithm
by deibyz (Hermit) on Aug 13, 2009 at 09:43 UTC
    You can also change the way perl sorts with the "sort" pragama (I think available from 5.8).

    perldoc sort for more information.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://788141]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-25 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found