Sorts by the given value.

@param string $field
@param string $direction

@return self
8414
public function sortBy(string $field, string $direction = 'asc'): self
    {
        $this->sortBy = [$field, $direction];

        return $this;
    }
1325794
public function orderBy($column, $direction = 'asc')
    {
        return $this->order($this->mapper->getFilterPropertyName($column), $direction);
    }
660930
public function sortByTimestamp($direction)
    {
        if ($this->id != '$ts') {
            throw new AnalyticsDbException('In order to sort by timestamp, you need to first group by timestamp.');
        }

        $direction = (int)$direction;
        $this->pipeline['$sort'] = ['_id' => $direction];

        return $this;
    }
278598
public function add_sort($field, $direction = 'ASC') {
        if (!isset($this->_query_modifiers['sort'])) {
            $this->_query_modifiers['sort'] = array();
        }

        $this->_query_modifiers['sort'][$field] = $direction;
    }
967264
public function setOrderBy($sort, $direction = 'ASC')
    {
        $this->sort = $sort;
        $this->direction = $direction;
        return $this;
    }
1360934
public function sort($field = null, $order = 'a') {
        if ($field === null) {
            $field = rqst('sort.name');
            $order = rqst('sort.dir', 'a');
        }
        if ($field) {
            if (is_string($field)) {
                $orders = explode(',', strtolower($order));
                $fields = explode(',', $field);
                foreach ($fields as $i => $field) {
                    $this->order [] = [$field, isset($orders[ $i ]) ? $orders[ $i ] : $orders[0]];
                }
            } else if (is_array($field)) {
                $this->sort($field[0], isset($field[1]) ? $field[1] : 'a');
            }
        }

        return $this;
    }
260545
public function order_by($property, $direction = 'ASC')
	{
		if (is_array($property))
		{
			foreach ($property as $p => $d)
			{
				if (is_int($p))
				{
					is_array($d) ? $this->order_by($d[0], $d[1]) : $this->order_by($d, $direction);
				}
				else
				{
					$this->order_by($p, $d);
				}
			}
			return $this;
		}

		// prefix table alias when not yet prefixed and not a DB expression object
		if ( ! $property instanceof \Fuel\Core\Database_Expression and strpos($property, '.') === false)
		{
			$property = $this->alias.'.'.$property;
		}

		$this->order_by[] = array($property, $direction);

		return $this;
	}
373205
public function orderBy($column, $direction = 'ASC')
    {
        $this->orderBy = $column;
        $this->orderByDirection = $direction;

        return $this;
    }
512277
public function orderBy($column, $direction = IQueryBuilder::ORDER_ASC)
    {
        if ($direction == IQueryBuilder::ORDER_ASC || $direction == IQueryBuilder::ORDER_DESC) {
            $this->orderConditions[$column] = $direction;
        }

        return $this;
    }
603898
public function orderBy(string $field, $order = 'asc')
    {
        $order = strtolower($order) == 'asc' ? 'asc' : 'desc';
        $this->ordination[$field] = $order;

        return $this;
    }
1326455
public function orderBy($column, $direction)
    {
        // Ensure the sort is valid
        if (in_array($column, $this->orderable) === false
            && array_key_exists($column, $this->orderable) === false
        ) {
            return $this;
        }

        // One time skip
        $this->skipOrderingOnce = true;

        return $this->addScopeQuery(function ($query) use ($column, $direction) {

            // Get valid sort order
            $direction = in_array(strtolower($direction), ['desc', 'asc']) ? $direction : 'asc';

            // Check for table column mask
            $column = Arr::get($this->orderable, $column, $column);

            return $query->orderBy($this->appendTableName($column), $direction);
        });
    }
1171992
public function sort($field, $direction = self::SORT_DESC) {
		if(empty($this->data['sorts'])) {
			$this->data['sorts'] = array();
		}
		$this->data['sorts'][] = array(
			'field' => $field,
			'direction' => $direction
		);
		return $this;
	}
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;
    }
187446
public static function create(array $properties, Direction $direction = null) : Sort
    {
        if ($direction === null) {
            $direction = Direction::$ASC;
        }
        $orders = [];
        foreach ($properties as $property) {
            $orders[] = new Order($direction, $property);
        }
        return new self($orders);
    }
377592
protected function orderByDirection($field, $direction, $prefixWithTableAlias = true)
    {
        $aliasInsert = $prefixWithTableAlias ? '?f:alias:.' : '';

        if ($this->orderSql == '') {
            $this->orderSql = " ORDER BY {$aliasInsert}?f {$direction}";
        } else {
            $this->orderSql .= ", {$aliasInsert}?f {$direction}";
        }
        $this->orderArguments[] = $field;
    }
271448
public function addOrder($field, $direction = SORT_ASC) {
		$this->query[self::ORDER][ $field ] = $direction;
		return $this;
	}
637591
public function sortByProperty( $property, $direction = null )
    {
        $this->sort( $this->generateSortByPropertyClosure( $property, $direction ) );
        return $this;
    }