Gist of the Day: Quicksort

Posted: 27th August 2013 by manchicken in Free Software, Gist of the Day, Hacking
Tags: , ,

So, I thought I’d just do a quick and simple quicksort implementation for you today. It’s nothing fancy, and there are certainly faster ways to do this (not involving making new arrays and such), but this is pretty simple.

Here’s the Gist:¬†https://gist.github.com/manchicken/6358106

  1. RandomMonkey says:

    This may be an academic exercise but perl’s own sort() routine used quicksort method internally until version 5.7, when it was replaced by a more stable but just as efficient mergesort. You can still access the quicksort via a pragma but that may be deprecated in future versions. There is more info on the man page http://perldoc.perl.org/functions/sort.html.

    • manchicken says:

      Yes, you are correct: Perl did use quicksort until 5.7 when it switched to mergesort (which was more efficient in more real-case scenarios).

      This was an exercise to demonstrate the algorithm.