php usort two columns
$users=array(
array("sex"=>0,"age"=>9),
array("sex"=>0,"age"=>34),
array("sex"=>1,"age"=>17),
array("sex"=>0,"age"=>1),
array("sex"=>1,"age"=>3)
);
//sort first by sex, then by age
usort($users, function($a,$b){
return ($a['sex'] == $b['sex']) ?
$a['age'] < $b['age'] :
$a['sex'] < $b['sex'];
});