Skip to content

Instantly share code, notes, and snippets.

@k1ic
Created November 3, 2016 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k1ic/631044b886e761919da92a20a3b846a6 to your computer and use it in GitHub Desktop.
Save k1ic/631044b886e761919da92a20a3b846a6 to your computer and use it in GitHub Desktop.
sort
private function _sort($arr = array(), $sort_filed = '', $sort_direction = self::HOT_LIST_SORT_ASC) {
$sort = array(
'direction' => $sort_direction, //排序顺序标志,SORT_DESC:降序,SORT_ASC:升序
'field' => $sort_filed, //排序字段
);
$arr_sort = array();
foreach ($arr as $uniqid => $row) {
foreach ($row as $k => $v) {
$arr_sort[$k][$uniqid] = $v;
}
}
if (isset($sort['direction'])) {
array_multisort($arr_sort[$sort['field']], constant($sort['direction']), $arr);
}
return $arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment