PHPEasy.co.uk: Sorting array data using SplMaxHeap
The SplMaxHeap class basically stores numbers in any order, and then returns them in descending order. In order to make this class useful for other data types other than numbers I have extend the SplMaxHeap class to compare dates and strings. SplMaxHeap extends SplHeap and implements the abstract class SplHeap::compare. Our extention of SplMaxHeap is therefore expected to implement the compare method.
Code examples are given showing sorting by things like "last name" and "date of birth" (using strtotime). There's also an example of its use in sorting values from an array and outputted in a loop. You can find out more about this functionality in the PHP manual.