Prepare sort orders for the request builder.

@return array()
13088
private function prepareSortOrders()
    {
        $sortOrders = [];

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

        return $sortOrders;
    }
1322337
public static function getOrder()
    {
        $cls = get_called_class();
        return array_key_exists($cls, self::$_order) ? self::$_order[$cls] : "";
    }
1070513
public function orderByToSort()
    {
        $sort = '';
        if (empty($this->orderBy) || !is_array($this->orderBy)) {
            return $sort;
        }
        foreach ($this->orderBy as $field => $direction) {
            $sort = ($direction == SORT_DESC ? '-' : '') . $field;
            break;
        }
        return $sort;
    }
896586
public function prepareOrderParam() {

        if (isset($this->request['order']) and ! empty($this->request['order'])) {
            $paramOrder = $this->request['order'];
            $returnOrder = Array();
            if (strlen($paramOrder) > 3) {
                if (is_int(strpos($paramOrder, "[")) and is_int(strpos($paramOrder, "]"))) {
                    $matches2 = $matches = null;
                    preg_match_all("/\[[^\]].*?\]/", $paramOrder, $matches, PREG_PATTERN_ORDER);
                    preg_match_all('/\=(.+)/s', $paramOrder, $matches2);
                    $returnOrder[0]['indexColumn'] = str_replace("]", '', str_replace("[", '', $matches[0][0]));
                    $returnOrder[0]['valueColumn'] = str_replace("=", '', $matches2[1][0]);
                }
            }
            return $returnOrder;
        } else {
            return null;
        }
    }
1227558
public function prepareRequest()
    {
        $version = $this->versionEngine->getVersion();
        $queryConfiguration = $version->parseRequest($this->columnConfigurations);
        $this->provider->prepareForProcessing($queryConfiguration, $this->columnConfigurations);

        return [
            'version' => $version,
            'queryConfiguration' => $queryConfiguration
        ];
    }
374679
private function setOrderBy()
    {
        if (isset($this->requestParams['order']) && count($this->requestParams['order'])) {
            $counter = count($this->requestParams['order']);

            for ($i = 0; $i < $counter; ++$i) {
                $columnIdx = (integer) $this->requestParams['order'][$i]['column'];
                $requestColumn = $this->requestParams['columns'][$columnIdx];

                if ('true' == $requestColumn['orderable']) {
                    $this->qb->addOrderBy(
                        $this->orderColumns[$columnIdx],
                        $this->requestParams['order'][$i]['dir']
                    );
                }
            }
        }

        return $this;
    }
593478
public function processListQueryOrderBy() {
		if (!empty($this->values['\Object\Form\Model\Dummy\Sort'])) {
			foreach ($this->values['\Object\Form\Model\Dummy\Sort'] as $k => $v) {
				if (!empty($v['__sort'])) {
					$name = $this->detail_fields['\Object\Form\Model\Dummy\Sort']['elements']['__sort']['options']['options'][$v['__sort']]['name'];
					$this->misc_settings['list']['sort'][$name] = $v['__order'];
					$this->query->orderby([$v['__sort'] => $v['__order']]);
				}
			}
		}
	}
1287373
protected function buildOrderJoin(string $order): array
    {
        list($column, $direction) = $this->formatOrderDirection($order);

        $lookupBuilder = $this->getLookupBuilder();

        $column = $lookupBuilder->fetchColumnName($column);
        $newOrder = $lookupBuilder->buildJoin($this, $column);
        if (false === $newOrder) {
            return [$column, $direction];
        }

        list($alias, $column) = $newOrder;

        return [
            $alias.'.'.$column,
            $direction,
        ];
    }
45299
protected function getOrderBy() {
		$order = [];
			
		foreach ($this->getOption('query.orderBy') as $attr) {
			$type = null;
			
			if ($attr instanceof Attr) {
				$name = $attr->getName();
				$type = $attr->getType();
			}
			elseif (is_string($attr)) {
				$expr = explode(' ', $attr);
				$name = $expr[0];
				
				if (count($expr) > 1) {
					$type = strtolower($expr[1]);
					if ($type != 'asc' && $type != 'desc')
						$type = null;
				}	
			}
			else
				throw new \InvalidArgumentException("Invalid order attribute defined: Expected a string or \eMapper\Query\Attr instance");
			
			$order[] = Attr::__callstatic($name)->type($type);
		}
		
		return $order;
	}
799806
public function prepareOrder()
    {
        $this->setPaymorrowPaymentMethodId();

        /** @var OxpsPaymorrowRequestControllerProxy $pmGateWay */
        $pmGateWay = oxNew('OxpsPaymorrowRequestControllerProxy');

        $oUtils = oxRegistry::getUtils();
        $oUtils->setHeader("Content-Type: application/json");
        $oUtils->showMessageAndExit($pmGateWay->prepareOrder($_POST));
    }
925880
protected function getListOrderAccount()
    {
        $conditions = $this->query_filter;
        $conditions['order'] = 'desc';
        $conditions['sort'] = 'created';
        $conditions['limit'] = $this->data_limit;
        $conditions['user_id'] = $this->data_user['user_id'];

        $list = (array) $this->order->getList($conditions);
        $this->prepareListOrderAccount($list);
        return $list;
    }
179153
public function getSorting(): array
    {
        if ($this->sorting === null) {
            $this->sorting = $this->setSorting();
        }

        return $this->sorting;
    }
465987
public function getOrderList()
    {
        if ($this->_aOrderList === null) {
            $this->_aOrderList = [];

            // Load user Orderlist
            if ($oUser = $this->getUser()) {
                $iNrofCatArticles = (int) \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('iNrofCatArticles');
                $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
                $this->_iAllArtCnt = $oUser->getOrderCount();
                if ($this->_iAllArtCnt && $this->_iAllArtCnt > 0) {
                    $this->_aOrderList = $oUser->getOrders($iNrofCatArticles, $this->getActPage());
                    $this->_iCntPages = ceil($this->_iAllArtCnt / $iNrofCatArticles);
                }
            }
        }

        return $this->_aOrderList;
    }
197569
public function getOrdered()
    {
        if (!$this->sort) {
            return $this->content;
        }

        $unordered = [];
        foreach ($this->content as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        $sort = json_decode($this->sort, true);
        $order = $sort['order'];
        foreach ($order as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
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;
    }
240605
protected function _prepareOrderByQuery($query = null)
    {
        // sorting
        $sortFields = $this->getListSorting();

        if (is_array($sortFields) && count($sortFields)) {
            // only add order by at full sql not for count(*)
            $query .= ' order by ';
            $addSeparator = false;

            $listItem = $this->getItemListBaseObject();
            $languageId = $listItem->isMultilang() ? $listItem->getLanguage() : \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();

            $descending = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('adminorder');
            $descending = $descending !== null ? (bool)$descending : $this->_blDesc;

            foreach ($sortFields as $table => $fieldData) {
                $table = $table ? (getViewName($table, $languageId) . '.') : '';
                foreach ($fieldData as $column => $sortDirectory) {
                    $field = $table . $column;

                    //add table name to column name if no table name found attached to column name
                    $query .= ((($addSeparator) ? ', ' : '')) . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quoteIdentifier($field);

                    //V oxActive field search always DESC
                    if ($descending || $column == "oxactive" || strcasecmp($sortDirectory, 'desc') == 0) {
                        $query .= ' desc ';
                    }

                    $addSeparator = true;
                }
            }
        }

        return $query;
    }
1124536
protected function order()
    {
        $order = '';
        if (isset($this->request['order']) && count($this->request['order'])) {
            $orderBy = [];
            for ($i = 0, $ien = count($this->request['order']);$i<$ien;$i++) {
                $columnIdx = intval($this->request['order'][$i]['column']);
                $column = $this->columns[$columnIdx];
                if (!isset($column['orderable']) || $column['orderable'] === true) {
                    $orderBy[] = $this->toSQLColumn($column, 2).' '.(!isset($this->request['order'][$i]['dir']) || $this->request['order'][$i]['dir'] === 'asc' ? 'ASC' : 'DESC');
                }
            }
            $order = ' ORDER BY '.implode(', ', $orderBy);
        }

        return $order;
    }