Get part of SQL query with ORDER BY condition

@param InternalOrderByInfo $orderBy Order by condition

@return string ORDER BY condition
347681
protected function getOrderByExpressionAsString(InternalOrderByInfo $orderBy)
    {
        $result = '';
        foreach ($orderBy->getOrderByInfo()->getOrderByPathSegments() as $order) {
            foreach ($order->getSubPathSegments() as $subOrder) {
                $result .= $result ? ', ' : '';
                $result .= $subOrder->getName();
                $result .= $order->isAscending() ? ' ASC' : ' DESC';
            }
        }
        return $result;
    }
425113
public function addOrderBy(string $orderBy, string $order)
    {
        if ($this->sql['orderby'] === null) {
            $this->sql['orderby'] = " ORDER BY ".$orderBy." ".$order." ";
        } else {
            $this->sql['orderby'] .= " , ".$orderBy." ".$order." ";
        }
    }
36393
public AnimaQuery<T> order(String columnName, OrderBy orderBy) {
        if (this.orderBySQL.length() > 0) {
            this.orderBySQL.append(',');
        }
        this.orderBySQL.append(' ').append(columnName).append(' ').append(orderBy.toString());
        return this;
    }
1217160
private function cleanOrderBy($table, $orderBy)
    {
        if (!empty($orderBy)) {
            $orderByArray = explode(',', $orderBy);
            foreach ($orderByArray as $k => $order) {
                $orderByArray[$k] = $table . '.' . $order;
            }
            $orderBy = implode(',', $orderByArray);
        }

        return $orderBy;
    }
986526
public function getOrderBy()
    {
        $orderby = $this->orderby;
        if (!$orderby) {
            $orderby = array();
        }

        if (!is_array($orderby)) {
            // spilt by any commas not within brackets
            $orderby = preg_split('/,(?![^()]*+\\))/', $orderby);
        }

        foreach ($orderby as $k => $v) {
            if (strpos($v, ' ') !== false) {
                unset($orderby[$k]);

                $rule = explode(' ', trim($v));
                $clause = $rule[0];
                $dir = (isset($rule[1])) ? $rule[1] : 'ASC';

                $orderby[$clause] = $dir;
            }
        }

        return $orderby;
    }
56888
protected function getOrderBys($order)
    {
        $separatedOrders = [$order];

        if ($this->isMultiOrderQuery($order)) {
            $separatedOrders = explode(',', $order);
        }

        return $separatedOrders;
    }
783677
public function sqlOrders()
    {
        if (!$this->hasOrders()) {
            return '';
        }

        $parts = [];
        foreach ($this->orders() as $order) {
            if (!$order instanceof DatabaseOrder) {
                $order = $this->createOrder($order->data());
            }

            $sql = $order->sql();
            if (strlen($sql) > 0) {
                $parts[] = $sql;
            }
        }

        if (empty($parts)) {
            return '';
        }

        return ' ORDER BY '.implode(', ', $parts);
    }
362852
protected function buildOrderBy()
    {
        if (!$this->order_by) {
            return '';
        }

        if ($this->order_asc) {
            return ' ORDER BY' . $this->indentCsv($this->order_by) . ' ASC';
        } else {
            return ' ORDER BY' . $this->indentCsv($this->order_by) . ' DESC';
        }
    }
1205129
public function orderBy() {
        $args = func_get_args();
        $this->build()->bindExpression('orderBy', $args[0] . " " . (empty($args[1]) ? ' ASC ' : " $args[1]"));

        return $this->connection;
    }
100615
public function parse(array $criteria, array $orderBy = array(), $limit = null, $offset = null)
    {
        $statement = new Expr\Statement();

        if(!empty($criteria)) {
            $statement->setClause('condition', $this->parseCriteria($criteria));
        }

        if(!empty($orderBy)) 
            $statement->setClause('order', $this->parseOrderBy($orderBy));
        if($limit)
            $statement->setClause('limit', $this->parseLimit($limit));
        if($offset)
            $statement->setClause('offset', $this->parseOffset($offset));

        return new Query($statement, $this->persister);
    }
1200209
public function getIn(
        $whereInKey,
        array $whereIn = [],
        array $with = [],
        string $orderBy = null,
        string $order = 'desc',
        int $limit = 0
    ) {
        $query = $this->make($with);

        $query = $query->whereIn($whereInKey, $whereIn);

        if ($orderBy) {
            $query = $query->orderBy($orderBy, $order);
        }

        if ($limit) {
            $query = $query->take($limit);
        }

        return $query->get();
    }
67863
final public function orderBy($orderby, $direction = '')
    {
        if (strtolower($direction) == 'random') {
            $orderby = ''; // Random results want or don't need a field name
            $direction = $this->_randomKeyword;
        } elseif (trim($direction) != '') {
            $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC';
        }


        if (strpos($orderby, ',') !== FALSE) {
            $temp = array();
            foreach (explode(',', $orderby) as $part) {
                $part = trim($part);
                if (!in_array($part, $this->arrayAliasedTables)) {
                    $part = $this->identifiers(trim($part));
                }
                $temp[] = $part;
            }

            $orderby = implode(', ', $temp);
        } else if ($direction != $this->_randomKeyword) {
            $orderby = $this->identifiers($orderby);
        }

        $orderbyStatement = $orderby . $direction;

        $this->arrayOrderBy[] = $orderbyStatement;
        if ($this->arrayCaching === TRUE) {
            $this->arrayCacheOrderBy[] = $orderbyStatement;
            $this->arrayCacheExists[] = 'orderby';
        }

        return $this;
    }
1161481
public function load(array $criteria, array $orderBy = null)
    {
        $stmt = $this->getMatchCypher($criteria, $orderBy);
        $result = $this->_em->getDatabaseDriver()->run($stmt->text(), $stmt->parameters());

        if ($result->size() > 1) {
            throw new \LogicException(sprintf('Expected only 1 record, got %d', $result->size()));
        }

        $hydrator = $this->_em->getEntityHydrator($this->_className);
        $entities = $hydrator->hydrateAll($result);

        return count($entities) === 1 ? $entities[0] : null;
    }
1328364
public function getOneResult($table, $where = null, $groupBy = null, $orderBy = null)
    {
        return $this->Select($table, $where, $groupBy, $orderBy, 1);
    }
949289
public function getAll($columns = null, $orderBy = 'created_at', $sort = 'desc')
    {
        $query = function () use ($columns, $orderBy, $sort) {

            return $this->model
                ->with($this->requiredRelationships)
                ->orderBy($orderBy, $sort)
                ->get($columns);

        };

        return $this->doQuery($query);
    }
1126553
public function getAll($orderBy = array('id', 'asc'))
    {
        list($column, $order) = $orderBy;

        return $this->newQuery()->orderBy($column, $order)->get();
    }
1205933
public function getPaginatorInstance($orderBy = 'updated_at', $order = 'desc')
    {
        if ($this->useSoftDeletes) {
            return $this->repository->withTrashed()->orderBy($orderBy, $order)->paginate();
        }

        return $this->repository->orderBy($orderBy, $order)->paginate();
    }