"Shaunak Kashyap" <firstname.lastname@example.org> wrote in message
> Does anyone know what sorting algorithm(s) -- quicksort, mergesort,
> radix sort, etc. -- does PHP use internally in its sort function?
There's a lot of sorting algorithms used by PHP. It looks like the primary
array sorting method is quicksort. I also found some use of mergesort.
Looking at the source, I found this:
This sets up the "hooks" for most of the array functions for use in Zend.
It looks like all of the sort methods rely on a sort_type == zend_qsort.
Doing a quick search for this in the rest of the source, returns this:
If you look at this file, you can see the good ol' quick sort algorithm in
action. If you prefer a different algorithm, I'm sure you could replace the
quicksort algorithm, recompile PHP, and whammo!
If you're interested in developing extensions to PHP, the API is pretty well
documented in the manual and in "Programming PHP" by Rasmus Lerdorf. I wish
I had the time to tinker with PHP at this level.