树形菜单数据

@param string $sort 排序字段
@return array
178081
public static function actionMenu($sort = '')
    {
        $user_id = \Yii::$app->request->get('user_id');

        $order = ExtHelpers::getOrder($sort, [
            'menu_id',
            'parent_id',
            'text',
            'title',
            'url',
            'view_package',
            'expanded',
            'closable',
            'is_open_url',
            'is_open_target',
            'is_every_open',
            'is_hide',
            'display_order',
            'note',
            'status',
        ], [], 'menu_id DESC');
        $tree = DpAdminMenu::getUserMenuTreeByParentId($user_id, null, $order);

        return [
            'children' => $tree,
        ];
    }
1243428
public function sort($sort = null)
    {
        deprecationWarning(
            'BelongToMany::sort() is deprecated. ' .
            'Use setSort()/getSort() instead.'
        );
        if ($sort !== null) {
            $this->setSort($sort);
        }

        return $this->getSort();
    }
52359
public function sort($sort)
    {
        if (null !== $sort && !is_array($sort)) {
            throw new \InvalidArgumentException(sprintf('The sort "%s" is not valid.', $sort));
        }

        $this->sort = $sort;

        return $this;
    }
1192698
public function sortByValue($sort = SORT_NUMERIC)
    {
        return $this
            ->groupBy(function (Card $card) {
                return $card->value();
            })
            ->map(function (CardCollection $valueGroup) {
                return $valueGroup->sortBySuitValue();
            })
            ->flatten()
            ->sortBy(function (Card $card) {
                return $card->value();
            }, $sort)
            ->values();
    }
882550
public function getData($order = self::SORT_DESC)
    {
        return array(
            'items' => array_map(
                function (Item $item) {
                    /*
                     * @var Item $item
                     */
                    return $item->toArray();
                },
                array_values($this->getItems($order))
            ),
        );
    }
11428
public function getSort()
    {
        $sorts = $get = $this->request->get('!sort') ?: array();

        foreach ($sorts as $key => &$value) {
            $value = (int) $value;
        }

        return $sorts;
    }
129111
public function getList($sort = null)
    {
        //Get the states list
        $states = $this->getStates();
        
        //Sorting
        $validSorts = [
            'iso_3166_2',
            'name',
            'country_code',
        ];
        
        if (! is_null($sort) && in_array($sort, $validSorts)) {
            uasort($states, function ($a, $b) use ($sort) {
                if (!isset($a[$sort]) && !isset($b[$sort])) {
                    return 0;
                } elseif (!isset($a[$sort])) {
                    return -1;
                } elseif (!isset($b[$sort])) {
                    return 1;
                } else {
                    return strcasecmp($a[$sort], $b[$sort]);
                }
            });
        }
        
        //Return the states
        return $states;
    }
27081
public function sort($sorts)
    {
        usort($this->rows, 
            function ($a, $b) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $sort => $direction) {
                    if (is_string($direction)) {
                        $cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ? 
                            $a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
                        $cmp = $direction === 'asc' ? $cmp : - $cmp;
                    } else if (is_callable($direction)) {
                        $cmp = $direction($a[$sort], $b[$sort]);
                    }
                    if ($cmp !== 0) {
                        break;
                    }
                }
                return $cmp;
            }
        );
        return $this;
    }
1048756
public function getOrderOption($sortValue)
    {
        $orders = array();
        if ($sortValue = trim($sortValue)) {
            $lines = array_map('trim', explode("\n", $sortValue));
            foreach ($lines as $line) {
                if (count($values = array_map('trim', explode(',', $line)))) {
                    $column = $values[0];
                    $order = (count($values) > 1) ? strtoupper($values[1]) : null;
                    if (!in_array($order, array('ASC', 'DESC'))) {
                        $order = 'ASC';
                    }
                    $orders[$column] = $order;
                }
            }
        }

        return $orders;
    }
24030
protected function _sortResult(array &$result, $sort = 'asort')
    {
        // Sorting
        switch ($sort) {
            case 'asort':
                asort($result);
                break;

            case 'ksort':
                ksort($result);
                break;

            case 'natsort':
                natsort($result);
                break;

            default:
                $sort($result);
        }
    }
29755
protected function checkOrder($order='') {
         if(is_string($order) && !empty($order)) {
            $orders = explode(',',$order);
            $_order = array();
            foreach ($orders as $order){
                $array  =   explode(' ',trim($order));
                $field  =   $array[0];
                $sort   =   isset($array[1])?$array[1]:'ASC';
                if(array_key_exists($field,$this->mapFields)){
                    // 需要处理映射字段
                    $field  =   $this->mapFields[$field];
                }                
                $_order[] = $field.' '.$sort;
            }
            $order = implode(',',$_order);
         }
        return $order;
    }
1370040
public function actionList($sort = '')
    {
        $order = ExtHelpers::getOrder($sort, [
            'rule_id',
            'route',
            'method',
            'host',
            'enable_rule',
            'note',
            'status'
        ], [], 'rule_id DESC');

        $list = [];

        $searchModel = new DpAdminMenuUrlRuleSearch();
        $dataProvider = $searchModel->search(\Yii::$app->request->get(), '');
        $dataProvider->query->orderBy($order);
        $dataProvider->getPagination()->pageSizeParam = 'limit';
        foreach ($dataProvider->getModels() as $itemModel) {
            /* @var $itemModel \wsl\rbac\models\DpAdminMenuUrl */
            $list[] = $itemModel->getAttributes();
        }

        return [
            'total' => $dataProvider->getTotalCount(),
            'list' => $list,
        ];
    }
678558
public function sort(array $sort = null) {
        if ($sort === null) {
            return $this->sort;
        }

        $this->sort = $sort;

        return $this;
    }
831246
public function prepareOrder($order = null, $sort = null)
    {
        if ($order == null or $sort == null) {
            $this->setOrderBy = '';

            return $this;
        }

        if (!in_array($sort, ['ASC', 'DESC'])) {
            $sort = 'DESC';
        }

        $this->setOrderBy = ' ORDER BY ' . $order . ' ' . $sort;

        return $this;
    }
92952
protected function _load(array $filter, array $sort)
    {
        $result = array();
        foreach ($this->getItemsOrdered() as $item) {
            $result[0][$item] = $item;
        }
        return $result;
    }
1262226
protected static function convertSort($sort)
  {
    /** @var RSort $convertedSort */
    $convertedSort = null;
    if (!empty($sort)) {
      $convertedSort = new RSort();
      $convertedSort->setField($sort->getField());
      switch ($sort->getOrder()) {
        case MSort\Order::Ascending:
          $convertedSort->setOrder(RSort\Order::Ascending);
          break;
        case MSort\Order::Descending:
          $convertedSort->setOrder(RSort\Order::Descending);
          break;
      }
    }
    return $convertedSort;
  }
764998
public function getFileList($order = 'desc')
    {
        if (! is_null($this->itemsOrderCache) && isset($this->itemsOrderCache[$order])) {
            return $this->itemsOrderCache[$order];
        }

        // Order Files by date newer to older
        $this->items->sort(function ($a, $b) use ($order) {
            if ($a == $b) {
                return 0;
            }
            if ($order === 'asc') {
                return ($a < $b) ? -1 : 1;
            }

            return ($a > $b) ? -1 : 1;
        });

        $this->itemsOrderCache[$order] = $this->items->all();

        return $this->itemsOrderCache[$order];
    }