"Matt Palermo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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
Off the top of my head.. <? $object_array = array( array( 'name' => 'Kevin', 'company' => 'IBM'), array( 'name' => 'Steve', 'company' => 'Apple'), array( 'name' => 'Bill', 'company' => 'Solaris') ); // Store names by group index.. foreach($object_array as $i => $a) { $sorted_array[$i] = $a['name']; } // Sort names and keep associated indicies.. asort($sorted_array); // Store original groups on sorted indicies.. foreach($sorted_array as $i => $v) { $sorted_object_array[$i] = $object_array[$i]; } echo "<pre>"; print_r($sorted_object_array); ?> Badda bing. - Kevin