Extrinsic sorting: A benchmark
Sorting algorithms are generally old hat to most programmers. They've either analyzed them to death in class, already written many of them, or work in a language where one is provided and they don't need to think about it. Or all three.
For PHP developers, we have a suite of sorting tools available to us: sort()
, usort()
, ksort()
, uasort()
, and various other letter combinations. All use Quick Sort internally, which is generally the best performing single-threaded option. Most importantly, many of them let us provide a custom comparison function to use when determining which of two values is larger or smaller.