name = $name; $this->position = $position; } } $data = array(new Data('Mary Johnson', 'Secretary'), new Data('Amanda Miller', 'Member'), new Data('James Brown', 'Member'), new Data('Patricia Williams', 'Member'), new Data('Michael Davis', 'President'), new Data('Sarah Miller', 'Vice-President'), new Data('Patrick Miller', 'Member')); /* start sort */ $sortorder = array('President', 'Vice-President', 'Secretary', 'Member'); function my_sort($a, $b) { global $sortorder; if($a->position == $b->position) { return strcmp($a->name, $b->name); } $cmpa = array_search($a->position, $sortorder); $cmpb = array_search($b->position, $sortorder); return ($cmpa > $cmpb) ? 1 : -1; } usort($data, 'my_sort'); /* end sort */ foreach($data as $o) { echo $o->name . ' ' . $o->position . "\r\n"; } ?>