What sort algorithm does PHP use?
You could find the information by looking at the php manual. http://php.net/sort says PHP uses an implementation of Quicksort. Failing that, you could always trudge through the PHP source code itself.
For sorting, PHP uses an implementation of quicksort that can be found in Zend/zend_sort.c
, which takes a comparison function and an array of elements. The default comparison function for sort()
is defined in ext/standard/array.c
and is called php_array_data_compare()
. So basically, it's the same algorithm for all sorting functions, except that they take different comparison functions.