function sort_array_by_feild($arr, $key1, $sort1, $key2='', $sort2='', $child_key_name=''){
if(!is_array($arr)){
return;
}
$main_key = array();
if($key2){
$assist_key = array();
}
foreach($arr as $key => $val){
$main_key[] = $val[$key1];
if($key2){
$assist_key[] = $val[$key2];
}
if($child_key_name && isset($val[$child_key_name])){
$arr[$key][$child_key_name] = sort_array_by_feild($val[$child_key_name], $key1, $sort1, $key2, $sort2, $child_key_name);
}
}
$sort1 = explode(',', $sort1);
if($key2 && $sort2){
$sort2 = explode(',', $sort2);
array_multisort($main_key, ($sort1[0]=='SORT_NUMERIC')?SORT_NUMERIC:SORT_STRING, ($sort1[1]=='SORT_DESC')?SORT_DESC:SORT_ASC, $assist_key, ($sort2[0]=='SORT_NUMERIC')?SORT_NUMERIC:SORT_STRING, ($sort2[1]=='SORT_DESC')?SORT_DESC:SORT_ASC, $arr);
}else{
array_multisort($main_key, ($sort1[0]=='SORT_NUMERIC')?SORT_NUMERIC:SORT_STRING, ($sort1[1]=='SORT_DESC')?SORT_DESC:SORT_ASC, $arr);
}
return $arr;
}