标签:
function list_sort_by($list, $field, $sortby = ‘desc‘) { if (is_array($list)) { $refer = $resultSet = array(); foreach ($list as $i => $data) { $refer[$i] = &$data[$field]; } switch ($sortby) { case ‘asc‘: // 正向排序 asort($refer); break; case ‘desc‘: // 逆向排序 arsort($refer); break; case ‘nat‘: // 自然排序 natcasesort($refer); break; } foreach ($refer as $key => $val) { $resultSet[] = &$list[$key]; } return $resultSet; } return false; }
标签:
原文地址:http://www.cnblogs.com/xuedong/p/5652373.html