@param array $orderBy In a form [expression => direction]

@return \Spiral\ORM\Helpers\AliasDecorator
178479
public function orderBy(array $orderBy): AliasDecorator
    {
        $this->query->orderBy($this->prepare($orderBy));

        return $this;
    }
1139192
final public static function all($orderBy = ['createdAt' => 'DESC'], bool $withTrash = false)
    {
        $criteria = self::criteriaWithSoftDelete([], $withTrash);
        return static::getRepository()
            ->findBy($criteria, $orderBy);
    }
1220238
protected function buildOrder($query, $filter, $order, $direction)
    {
        if (!empty($order)) {
            $direction = empty($direction) ? 'asc' : $direction;
            $query     = $query->orderBy($order, $direction);
        }

        return $query;
    }
47040
private function sortWithEncryptedOrderBy($values, array $orderBy)
    {
        usort($values, function($entity1, $entity2) use ($orderBy) {
            foreach ($orderBy as $fieldName => $order) {
                $value1 = $this->getFieldValue($entity1, $fieldName);
                $value2 = $this->getFieldValue($entity2, $fieldName);

                if ($value1 < $value2) {
                    return (strtoupper($order) === 'ASC') ? -1 : 1;
                }
                elseif ($value1 > $value2) {
                    return (strtoupper($order) === 'ASC') ? 1 : -1;
                }
            }

            // If we are here is because all the values were equal
            return 0;
        });

        return $values;
    }
111503
public function OrderBy($Fields, $Direction = 'asc') {
      if (!$Fields)
         return $this;
         
      if ($Direction && $Direction != 'asc')
         $Direction = 'desc';
      else
         $Direction = 'asc';

      $this->_OrderBys[] = $this->EscapeIdentifier($Fields, TRUE).' '.$Direction;
      return $this;
   }
970804
public function orderBy($field, $direction = 'asc')
    {
        $this->setOrderByField($field);
        $this->setOrderByDirection($direction);

        return $this;
    }
112225
public function order($order, $direction = self::ASC)
    {
        $this->order = $order;
        $this->direction = $direction;
        return $this;
    }
1205129
public function orderBy() {
        $args = func_get_args();
        $this->build()->bindExpression('orderBy', $args[0] . " " . (empty($args[1]) ? ' ASC ' : " $args[1]"));

        return $this->connection;
    }
222646
public function orderBy($orderBy = NULL) {
        if (isset($orderBy)) {
            $this->setOrderBy($orderBy);
            return $this;
        }
        return $this->getOrderBy();
    }
509144
final public function orderBy(string $orderBy, string $order = 'ASC')
    {        
       $this->query->addOrderBy($orderBy, $order);

        return $this;
    }
471881
public static function sort_terms( $terms, $orderby = 'term_id', $order = 'ASC' ) {

		if ( function_exists( 'wp_list_sort' ) ) {
			$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
		} else {

			if ( 'name' === $orderby ) {
				usort( $terms, '_usort_terms_by_name' );
			} else {
				usort( $terms, '_usort_terms_by_ID' );
			}

			if ( 'DESC' === $order ) {
				$terms = array_reverse( $terms );
			}
		}

		return $terms;
	}
1117960
public function findOneBy(array $criteria, array $orderBy = null)
    {
        $qb = $this->findWithCriteria($criteria, $orderBy);
        $result = $qb->execute()->fetch();

        if ($result) {
            return $this->hydrate($result, $qb);
        }

        return false;
    }
391723
protected function createPaginatedQueryBuilder(array $criteria = [], $indexBy = null, array $orderBy = null)
    {
        $qb = new PaginatedQueryBuilder($this->_em);
        $qb->from($this->_entityName, $this->getEntityAlias(), $indexBy);

        $this->processCriteria($qb, $criteria);

        return $qb;
    }
851372
public function findOneBy(array $criteria, array $orderBy = null)
    {
        $models = $this->findBy($criteria, $orderBy, 1, 0);

        if ([] === $models) {
            $this->logger->notice(
                'model: row within table {table} with criteria {criteria} not found',
                [
                    'table' => $this->getTable(),
                    'criteria' => $criteria,
                    'orderBy' => $orderBy,
                    'limit' => 1,
                    'offset' => 0,
                ]
            );

            return null;
        }

        return reset($models);
    }
313370
public function orderBy($orderBy = null) {
		if (is_array($orderBy))
			$this->orderByClause = $orderBy;
		else
			$this->orderByClause = func_get_args();
		return $this;
	}
1282679
public function addOrderBy(array $orderBy): void
    {
        if (empty($orderBy)) {
            return;
        }
        $orderByList = [];
        foreach ($orderBy as $clause) {
            $clause['key'] = $this->quoteName($clause['key']);
            array_push($orderByList, $clause['key'] . ' ' . $clause['direction']);
        }
        $pattern = ' ORDER BY %s';
        $this->statement .= sprintf($pattern, implode(', ', $orderByList));
        $this->statement .= PHP_EOL;
    }
1070322
protected final function getOrderBySQL(array $orderBy, $baseTableAlias)
    {
        $orderByList = array();

        foreach ($orderBy as $fieldName => $orientation) {

            $orientation = strtoupper(trim($orientation));

            if ($orientation != 'ASC' && $orientation != 'DESC') {
                throw ORMException::invalidOrientation($this->class->name, $fieldName);
            }

            if (isset($this->class->fieldMappings[$fieldName])) {
                $tableAlias = isset($this->class->fieldMappings[$fieldName]['inherited'])
                    ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited'])
                    : $baseTableAlias;

                $columnName    = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform);
                $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation;

                continue;
            }

            if (isset($this->class->associationMappings[$fieldName])) {

                if ( ! $this->class->associationMappings[$fieldName]['isOwningSide']) {
                    throw ORMException::invalidFindByInverseAssociation($this->class->name, $fieldName);
                }

                $tableAlias = isset($this->class->associationMappings[$fieldName]['inherited'])
                    ? $this->getSQLTableAlias($this->class->associationMappings[$fieldName]['inherited'])
                    : $baseTableAlias;

                foreach ($this->class->associationMappings[$fieldName]['joinColumns'] as $joinColumn) {
                    $columnName    = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform);
                    $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation;
                }

                continue;
            }

            throw ORMException::unrecognizedField($fieldName);
        }

        return ' ORDER BY ' . implode(', ', $orderByList);
    }