Get sort structure.

@return array
1744
public function getSortStructure()
    {
        $sort = [$this->getField() => (object)['order' => $this->getOrder()]];

        if ($this->getMode()) {
            $sort[$this->getField()]->mode = $this->getMode();
        }
        if ($this->getMissing()) {
            $sort[$this->getField()]->missing = $this->getMissing();
        }

        return (object)$sort;
    }
262063
public function sortProcess()
    {
        $sorts = [];
        foreach ($this->params as $field => $direction) {
            $sorts[trim($field)] = is_string($direction) ?
            trim($direction) : $direction;
        }

        usort(
            $this->data,
            function ($a1, $a2) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $field => $direction) {
                    $v1 = Util::get($a1, $field, 0);
                    $v2 = Util::get($a2, $field, 0);
                    if ($direction === 'asc' || $direction === 'desc') {
                        if (is_numeric($v1) && is_numeric($v2)) {
                            if ($v1 < $v2) {
                                $cmp = -1;
                            } elseif ($v1 > $v2) {
                                $cmp = 1;
                            }

                        } else {
                            $cmp = strcmp($v1, $v2);
                        }
                        if ($direction === 'desc') {
                            $cmp = -$cmp;
                        }

                    } else if (is_callable($direction)) {
                        $cmp = $direction($v1, $v2);
                    }

                    if ($cmp !== 0) {
                        break;
                    }

                }
                return $cmp;
            }
        );
    }
395890
public function sort()
    {
        array_multisort(array_map(function ($pair) {
            return mb_convert_encoding($pair[0], 'UTF-16BE', 'UTF-8');
        }, $this->list), SORT_STRING, range(1, count($this->list)), $this->list);
    }
668382
public function getGridOrder() {
        $criteria = Yii::$app->session[$this->sessionVarName];
        return self::convertGridSort($criteria);
    }
1129462
protected function arrayOrderBy()
    {
        $arguments = func_get_args();
        $data = array_shift($arguments);
        foreach ($arguments as $argument => $field) {
            if (is_string($field)) {
                $temp = [];
                foreach ($data as $key => $row) {
                    $temp[$key] = $row[$field];
                }
                $arguments[$argument] = $temp;
            }
        }
        $arguments[] = &$data;
        call_user_func_array('array_multisort', $arguments);

        return array_pop($arguments);
    }
11428
public function getSort()
    {
        $sorts = $get = $this->request->get('!sort') ?: array();

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

        return $sorts;
    }
1367061
protected function sortData() {
        $columns = $this->getOrder();
        $order = [];
        foreach ($columns as $column) {
            if ($column[0] === '-') {
                $column = substr($column, 1);
                $order[$column] = -1;
            } else {
                $order[$column] = 1;
            }
        }

        $cmp = function ($a, $b) use ($order) {
            foreach ($order as $column => $desc) {
                $r = strnatcmp($a[$column], $b[$column]);

                if ($r !== 0) {
                    return $r * $desc;
                }
            }
            return 0;
        };

        usort($this->data, $cmp);
    }
999057
public function sort()
    {
        $deps = $this->all();
        $sorted = $this->sortDeps($deps);

        return $this->dependency->getSorted($sorted);
    }
1296274
public function sortedTables(): array
    {
        $items = array_keys($this->tables);
        $this->states = $this->stack = [];

        foreach ($items as $item) {
            $this->sort($item, $this->dependencies[$item]);
        }

        return $this->stack;
    }
648225
protected function _getSortFields()
    {
        $sortFields = [];

        foreach ($this->controller->sortFields as $field => $options) {
            if (isset($options['actions']) &&
                is_array($options['actions']) &&
                in_array($this->action, $options['actions'])
            ) {
                $sortFields[$field] = $options;
            }
        }

        return $sortFields;
    }
216346
public function getListSorting()
    {
        if ($this->_aCurrSorting === null) {
            $this->_aCurrSorting = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('sort');

            if (!$this->_aCurrSorting && $this->_sDefSortField && ($baseObject = $this->getItemListBaseObject())) {
                $this->_aCurrSorting[$baseObject->getCoreTableName()] = [$this->_sDefSortField => "asc"];
            }
        }

        return $this->_aCurrSorting;
    }
13088
private function prepareSortOrders()
    {
        $sortOrders = [];

        foreach ($this->_orders as $attribute => $direction) {
            $sortParams = ['direction' => $direction];
            $sortField = $attribute;
            $sortOrders[$sortField] = $sortParams;
        }

        return $sortOrders;
    }
67441
public function actionSort() 
    {
        $this->layout = static::FORM_LAYOUT;
        $modelName = $this->getCompatibilityId();
        if(isset($_POST[$modelName]) && count($_POST[$modelName])) {
            //If we are changing the main categories then use a different algorithm
            if($_GET['Menu_id']==-1) {
                foreach($_POST[$modelName] as $key => $id) {
                    $record = $this->findModel($id);
                    $record->sort_order = $key+1;
                    $record->save();
                }
            } else {
                $parent = $this->findModel($_GET['Menu_id']);
                foreach($_POST[$modelName] as $key => $id) {
                    $record = $this->findModel($id);
                    $record->appendTo($parent);
                }
            }
            return $this->redirect(['index']);
        } else {
            $this->getSearchCriteria();
            $searchCriteria = ['MenuSearch' => ['Menu_id' => $this->searchModel->Menu_id]];
            $this->searchModel = new $this->MainModelSearch;
            $this->dataProvider = $this->searchModel->search($searchCriteria);

            $this->dataProvider->pagination = false;
            return $this->render('sort', [
                'searchModel' => $this->searchModel,
                'dataProvider' => $this->dataProvider,
            ]);         
        }
    }
280180
public function getSortedList()
    {
        $this->addVariables();

        // Find all items that don't have their order specified by the config system
        $unspecified = array_diff($this->names, $this->priorities);

        if (!empty($unspecified)) {
            $this->includeRest($unspecified);
        }

        $sortedList = [];
        foreach ($this->priorities as $itemName) {
            if (isset($this->items[$itemName])) {
                $sortedList[$itemName] = $this->items[$itemName];
            }
        }

        return $sortedList;
    }
325196
public function getListSorting()
    {
        $sSortParameter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('sort');
        if ($this->_aCurrSorting === null && !$sSortParameter && ($oBaseObject = $this->getItemListBaseObject())) {
            $sCatView = $oBaseObject->getCoreTableName();

            $this->_aCurrSorting[$sCatView]["oxrootid"] = "desc";
            $this->_aCurrSorting[$sCatView]["oxleft"] = "asc";

            return $this->_aCurrSorting;
        } else {
            return parent::getListSorting();
        }
    }
131620
public function getOrderedItems()
    {
        if (config('menus.ordering') || $this->ordering) {
            return $this->toCollection()->sortBy(function ($item) {
                return $item->order;
            })->all();
        }

        return $this->items;
    }
186420
public function get_sort_columns() {
        if (!$this->setup) {
            throw new coding_exception('Cannot call get_sort_columns until you have called setup.');
        }

        if (empty($this->prefs['sortby'])) {
            return array();
        }

        foreach ($this->prefs['sortby'] as $column => $notused) {
            if (isset($this->columns[$column])) {
                continue; // This column is OK.
            }
            if (in_array($column, get_all_user_name_fields()) &&
                    isset($this->columns['fullname'])) {
                continue; // This column is OK.
            }
            // This column is not OK.
            unset($this->prefs['sortby'][$column]);
        }

        return $this->prefs['sortby'];
    }