标签:derby blog erb code desc ret new asc sort
$arr = array( ‘11‘=>array( ‘a‘=>1, ‘b‘=>2, ), ‘22‘=>array( ‘a‘=>3, ‘b‘=>4, ), ‘33‘=>array( ‘a‘=>5, ‘b‘=>6, ) ); $data = $this->array_sort($arr,‘a‘,‘desc‘,‘yes‘); private function array_sort($arr,$keys,$orderby=‘asc‘,$key=‘no‘){ $keysvalue = $new_array = array(); foreach($arr as $k=>$v){ $keysvalue[$k] = $v[$keys]; } if($orderby==‘asc‘){ asort($keysvalue); }else{ arsort($keysvalue); } reset($keysvalue); foreach($keysvalue as $k=>$v){ if($key==‘yes‘){ $new_array[$k] = $arr[$k]; }else{ $new_array[] = $arr[$k]; } } return $new_array; }
标签:derby blog erb code desc ret new asc sort
原文地址:http://www.cnblogs.com/zengdiao/p/6074438.html