1$users=array(
2 array("sex"=>0,"age"=>9),
3 array("sex"=>0,"age"=>34),
4 array("sex"=>1,"age"=>17),
5 array("sex"=>0,"age"=>1),
6 array("sex"=>1,"age"=>3)
7);
8//sort first by sex, then by age
9usort($users, function($a,$b){
10 return ($a['sex'] == $b['sex']) ?
11 $a['age'] < $b['age'] :
12 $a['sex'] < $b['sex'];
13});