Adds an order by clause
@chainable
325884
public function orderBy($sql, $params=array())
    {
        $binder = new Binder();
        $this->_order = array($binder->magicBind($sql, (array) $params));

        return $this;
    }
1231726
public function setOrder(\Core\Entity\Order $order = null) {
        $this->order = $order;

        return $this;
    }
270169
public function addOrders(Order ...$orders): MutableQuery
    {
        $cloned = clone $this;

        $activeOrders = iterator_to_array($this->orders);
        $activeOrders = array_merge($activeOrders, $orders);

        $cloned->orders = new OrderCollection(...$activeOrders);

        return $cloned;
    }
243734
protected function applyOrderBy(QueryBuilder $qb, $orderBy)
    {
        foreach ($orderBy as $order) {
            $column = $order->getField();
            if (strpos($column, '.') !== false) {
                [$relation, $column] = explode('.', $column);
                $childAlias = 'orderBy'.ucfirst($relation);
                $qb->leftJoin("{$this->queryAlias}.{$relation}", $childAlias);
                $qb->addOrderBy("$childAlias.$column", $order->getDirection());
            } else {
                if ($this->objectDefinition && $this->objectDefinition->hasField($column)) {
                    $column = $this->objectDefinition->getField($column)->getOriginName() ?: $column;
                }
                $qb->addOrderBy("{$this->queryAlias}.$column", $order->getDirection());
            }
        }
    }
329329
public function ordered($orderBy = 'orderby', $orderDir = 'orderdir')
	{
		// Look for our request vars of interest
		$this->orderBy  = \Request::getCmd($orderBy, $this->getState('orderby', $this->orderBy));
		$this->orderDir = \Request::getCmd($orderDir, $this->getState('orderdir', $this->orderDir));

		$qualifiedOrderBy = $this->orderBy;

		// If we have a '.' we'll assume the prefix is a relationship name
		if (strpos($this->orderBy, '.') !== false)
		{
			list($relationship, $field) = explode('.', $this->orderBy);

			// We have to join to apply the order by clause
			$relationship     = $this->$relationship()->join();
			$qualifiedOrderBy = $relationship->getQualifiedFieldName($field);
		}

		// Apply order clause
		$this->order($qualifiedOrderBy, $this->orderDir);

		// Set state for future use
		$this->setState('orderby', $this->orderBy);
		$this->setState('orderdir', $this->orderDir);

		return $this;
	}
1234940
private void addSortOrder(SearchRequestBuilder builder, KunderaQuery query, EntityMetadata entityMetadata)
    {
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                .getMetamodel(entityMetadata.getPersistenceUnit());

        List<OrderByItem> orderList = KunderaQueryUtils.getOrderByItems(query.getJpqlExpression());

        for (OrderByItem orderByItem : orderList)
        {
            String ordering = orderByItem.getOrdering().toString();

            if (ordering.equalsIgnoreCase(ESConstants.DEFAULT))
            {
                ordering = Expression.ASC;
            }

            builder.addSort(KunderaCoreUtils.getJPAColumnName(orderByItem.getExpression().toParsedText(),
                    entityMetadata, metaModel), SortOrder.valueOf(ordering));
        }
    }
58286
public function addOrderBy($void = null)
    {
        $this->ensureNoArguments(__METHOD__, $void);

        return $this->addChild(new OrderByAdd($this));
    }
699001
public function orderBy($field, $order = 'ASC')
    {
        if(is_string($field) && trim($field) != '') {
            $field = trim($field);
            $field = ltrim($field, 'ORDER BY ');
            $this->order = ' ORDER BY `'.$field.'`'.(($order == 'DESC') ? ' DESC' : ' ASC');
        }
        return $this;
    }
43589
public function OrderBy($Value = NULL) {
      if ($Value === NULL)
         return $this->_OrderBy;

      if (is_string($Value))
         $Value = array($Value);

      if (is_array($Value)) {
         // Set the order of this object.
         $OrderBy = array();

         foreach($Value as $Part) {
            if (StringEndsWith($Part, ' desc', TRUE))
               $OrderBy[] = array(substr($Part, 0, -5), 'desc');
            elseif (StringEndsWith($Part, ' asc', TRUE))
               $OrderBy[] = array(substr($Part, 0, -4), 'asc');
            else
               $OrderBy[] = array($Part, 'asc');
         }
         $this->_OrderBy = $OrderBy;
      } elseif (is_a($Value, 'Gdn_SQLDriver')) {
         // Set the order of the given sql.
         foreach ($this->_OrderBy as $Parts) {
            $Value->OrderBy($Parts[0], $Parts[1]);
         }
      }
   }
211786
public function setOrderByClause(Clause\OrderBy $objOrderByClause)
    {
        if ($this->objOrderByClause) {
            throw new Caller('You can only have one OrderBy clause in a query.');
        }
        $this->objOrderByClause = $objOrderByClause;
    }
980671
@NonNull
    @Override
    public OrderBy orderBy(@NonNull Ordering... orderings) {
        if (orderings == null) {
            throw new IllegalArgumentException("orderings is null.");
        }
        return new OrderBy(this, Arrays.asList(orderings));
    }
149210
function orderby (args, order) {
    if (this.typecheck) t.typecheck('orderby', [args, order]);
    
    var o = (order&&'string'===typeof order) ? order : '';
    var result = [];

    if ('string'===typeof args) {
        result = o ? [args+' '+o] : [args];
    }
    else if (args instanceof Array) {
        for (var i=0; i < args.length; i++) {
            if ('string'===typeof args[i]) {
                o ? result.push(args[i]+' '+o) : result.push(args[i]);
            }
            else if ('object'===typeof args[i]) {
                var key = Object.keys(args[i])[0];
                result.push(key+' '+args[i][key]);
            }
        }
    }
    else if (args instanceof Object) {
        var key = Object.keys(args)[0];
        result = [key+' '+args[key]];
    }

    return 'order by '+result.join();
}
853997
public function orderBy($field, $order = 'asc'){
        $this->model = $this->model->orderBy(...func_get_args());
        return $this;
    }
324319
def add_order_by_for_association_limiting!(sql, options)
      return sql if options[:order].blank?

      order_columns = extract_order_columns(options[:order]) do |columns|
        columns.map! { |s| $1 if s =~ / (.*)/ }; columns
      end
      order = order_columns.map { |s, i| "alias_#{i}__ #{s}" } # @see {#distinct}

      sql << "ORDER BY #{order.join(', ')}"
    end
342376
public function getOrderBy()
    {
        $template = "ORDER BY %s";
        $orderBy = null;
        if (!is_null($this->_sql->orderBy)) {
            $orderBy = trim(sprintf($template, $this->_sql->getOrderBy()));
        }
        return $orderBy;
    }
1130836
public function OrderByClause()
    {
        $this->match(Lexer::T_ORDER);
        $this->match(Lexer::T_BY);

        $orderByItems   = [];
        $orderByItems[] = $this->OrderByItem();

        while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
            $this->match(Lexer::T_COMMA);

            $orderByItems[] = $this->OrderByItem();
        }

        return new AST\OrderByClause($orderByItems);
    }
668904
public function getFindByQuery(array $criteria = null, array $orderBy = null, $limit = null, $offset = null)
    {
        /** @var \Doctrine\ORM\QueryBuilder $qb */
        $qb = $this->createQueryBuilder('e');

        $firstCriteria = true;
        if (!empty($criteria)) {
            foreach ($criteria as $field => $value) {
                if ($firstCriteria) {
                    if ($value === null or $value === 'null') {
                        $qb->where("e.$field IS NULL");
                    } elseif ($value === 'not null') {
                        $qb->where("e.$field IS NOT NULL");
                    } else {
                        $qb->where("e.$field = :$field");
                        $qb->setParameter($field, $value);
                    }

                    $firstCriteria = false;
                } else {
                    if ($value === null or $value === 'null') {
                        $qb->andWhere("e.$field IS NULL");
                    } elseif ($value === 'not null') {
                        $qb->andWhere("e.$field IS NOT NULL");
                    } else {
                        $qb->andWhere("e.$field = :$field");
                        $qb->setParameter($field, $value);
                    }
                }
            }
        }

        $firstOrderBy = true;
        if (!empty($orderBy)) {
            foreach ($orderBy as $field => $value) {
                if ($firstOrderBy) {
                    $qb->orderBy("e.$field", $value);
                    $firstOrderBy = false;
                } else {
                    $qb->addOrderBy("e.$field", $value);
                }
            }
        }

        if (!empty($limit)) {
            $qb->setMaxResults($limit);
        }

        if (!empty($offset)) {
            $qb->setFirstResult($offset);
        }

        return $qb->getQuery();
    }