Writing a comparison function and using http://www.php.net/manual/en/function.uasort.php would be a great deal more readable.