You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wkcrm/application/bi/traits/SortTrait.php

29 lines
466 B

<?php
/**
* 排序帮助类
*
* @author qifna
* @date 2020-12-25
*/
namespace app\bi\traits;
trait SortTrait
{
/**
* 数组排序
*
* @param $data
* @param $field
* @param $sort
* @return mixed
*/
public function sortCommon($data, $field, $sort)
{
$sortField = array_column($data, $field);
array_multisort($sortField,$sort == 'desc' ? SORT_DESC : SORT_ASC, $data);
return $data;
}
}