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:¬†

  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

    • 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.