I have an array of object for files on my site. The objects hold a file's name, size, extension, etc... I was wondering if anyone knows where I could find a relatively easy function for sorting the array of these objects by either name, size, etc... Please let me know if got any tips. Thanks a lot!
Matt
function sort_objects_by_name($a, $b) { if ($a->name == $b->name) return 0; return ($a->name > $b->name) ? -1 : 1; }
usort($objects, 'sort_objects');
It might work to define the function as function sort_objects_by_name(&$a, &$b), try it yourself
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php