Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Quicksort problem

by Marshall (Prior)
on Nov 22, 2011 at 08:50 UTC ( #939389=note: print w/ replies, xml ) Need Help??


in reply to Quicksort problem

Perl sort() has been and continues to be vastly improved. Sometimes there is a tiny step backward, but usually there is a big step forward.

I recommend that you use Perl sort() rather than trying to implement a my_sort() routine yourself.

Update: I skipped Perl 5.8 and went straight from 5.6 to 5.10. I know that the worst case quicksort issue (already ordered) went away. But more happened than just that. The sorting got significantly faster. Probably a combination of algorithm and implementation changes? I have not investigated all of the details. I just know that it is a lot faster. The sort time got so much better that it has caused me to re-think many places where I used techniques like Schwartzian transform.

As a learning exercise, I think one should be familiar with all the basic sorting algorithms. There is a lot to be learned from that and there is a reason why this is taught in every CS curriculum. I guess I just wound up with a very long winded way of saying: the Perl sort() function is no slouch!


Comment on Re: Quicksort problem
Re^2: Quicksort problem
by MidLifeXis (Prior) on Nov 22, 2011 at 11:30 UTC

    While this is usually true in Perl, learning how different sorts work, how to implement them yourself, bigOh analysis of them, and under what scenarios they should or should not be used have great value.

    When in college, we had two schools teaching "computer science" - the CS program under the sciences, and one of the business tracks under the school of business. The school of business basically taught the students to use the foo function of the language de jour to do action bar. I helped a few people in my circle of influence from the business school wow their instructors (How's that so fast?) and classes by teaching them some of those differences. I also took on some projects speeding up code submitted by other (Update: I was in CS, not Business) business students as projects for departments around campus.

    My point is that even if the language's sort is the best for the purpose, it does not hurt to learn other methods, nor is it bad to know why it is the best for the purpose. Trying to implement it oneself can also give insight as to why the language's sort is the better choice.

    --MidLifeXis

Re^2: Quicksort problem
by JediMasterT (Sexton) on Nov 23, 2011 at 02:32 UTC

    Interestingly enough, up until 5.8, Perl used Quicksort for sort()

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-12-21 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (100 votes), past polls