/**
* 二维数组根据字段进行排序
* @params array $array 需要排序的数组
* @params string $field 排序的字段
* @params string $sort 排序顺序标志 SORT_DESC 降序;SORT_ASC 升序
*/
//单条件排序
function arraySequence($array, $field, $sort = 'SORT_DESC')
{
$arrSort = array();
foreach ($array as $uniqid => $row) {
foreach ($row as $key => $value) {
$arrSort[$key][$uniqid] = $value;
}
}
array_multisort($arrSort[$field], constant($sort), $array);
return $array;
}
//多条件排序
if (count($ask_lists_sort)>0)
{
foreach ($ask_lists_sort as $k_2 => $v_2)
{
$heard_num_1[$k_2] = $v_2 -> heared_num;
$time_1[$k_2] = $v_2 -> created_at;
}
array_multisort($heard_num_1, SORT_DESC, $time_1, SORT_DESC, $ask_lists_sort);
}