assume you have the following array:
$arr=array( array('field1'=>108, 'field2'=>'some'), array('field1'=>200, 'field2'=>'zen'), array('field1'=>105, 'field2'=>'bar'), array('field1'=>100, 'field2'=>'foo'), array('field1'=>200, 'field2'=>'yellow'), array('field1'=>200, 'field2'=>'any'), ); How would you approach if you want to sort the array first by field1 and then by field2. That is sort the array by field1 but for field1 values that are same, sort by field two.. just like the SQL equivalent of ORDER By column1, colum2..usort($arr, function($a, $b){ if ($a['field1']>$b['field1']){ return 1; }elseif($a['field1']<$b['field1']){ return -1; }else{ return strcasecmp($a['field2'], $b['field2']); } });