Set sort field and direction

@param string $field     Field name
@param string $direction Sort direction
@param int    $priority  Priority
@return self
1537
public function addSort($field = 'time_created', $direction = 'DESC', $priority = 500) {

		if (!$field || !$direction) {
			return $this;
		}

		while (isset($this->sorts[$priority])) {
			$priority++;
		}

		$field = sanitize_string($field);
		$direction = strtoupper(sanitize_string($direction));

		if (!in_array($direction, array('ASC', 'DESC'))) {
			$direction = self::DEFAULT_SORT_DIRECTION;
		}

		$this->removeSort($field);

		$this->sorts[$priority] = [
			'field' => $field,
			'direction' => $direction,
		];

		ksort($this->sorts);

		return $this;
	}
672751
public function orderBy($fields, $direction = false)
    {
        $this->orderBy->addFields($fields, $direction);

        return $this;
    }
637591
public function sortByProperty( $property, $direction = null )
    {
        $this->sort( $this->generateSortByPropertyClosure( $property, $direction ) );
        return $this;
    }
1332417
public function setSorting($sortingName, $direction = 'asc')
    {
        $value = $sortingName . ' ' . $direction;
        $path = $this->prefixWithNamespace('sort');
        $this->argumentsAccessor->set($path, $value);
        $this->stateChanged = true;
        return $this;
    }
1214027
public function byFieldValue(
        string $field,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FIELD,
            'field' => Item::getPathByField($field),
            'order' => $order,
        ];

        return $this;
    }
854639
public function orderBy($field, $direction = 'asc')
    {
        $this->sort = $field;
        $this->sortDirection = $direction;

        return $this;
    }
1205950
public function orderBy(string $key, string $direction = 'ASC'): SelectQueryBuilder
    {
        array_push($this->orderBy, [
            'key' => $key,
            'direction' => strtoupper($direction),
        ]);
        return $this;
    }
1187245
public function orderByFixed($index, $direction = 'desc')
    {
        if ($direction != 'desc') {
            $direction = 'asc';
        }

        if (is_array($index)) {
            $this->attributes['orderFixed'][] = $index;
        } else {
            $this->attributes['orderFixed'][] = [$index, $direction];
        }

        return $this;
    }
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;
	}
1110059
public function orderBy($index, $direction = 'desc')
    {
        if ($direction != 'desc') {
            $direction = 'asc';
        }

        if (is_array($index)) {
            $this->attributes['order'][] = $index;
        } else {
            $this->attributes['order'][] = [$index, $direction];
        }

        return $this;
    }
601633
public function setSortData($column, $direction = null)
    {
        if (null === $column) {
            return $this->clearSortData();
        }

        session()->put($this->getSessionKey(static::TYPE_SORT), [
            'column'    => $column,
            'direction' => $direction,
        ]);

        return $this;
    }
452560
public function orderBy($column, $direction = 'ASC')
    {
        $orderVal         = [
            'ASC'  => 1,
            'DESC' => -1,
        ];
        $this->ordering[] = [
            'column'    => $column,
            'direction' => $orderVal[strtoupper($direction)],
        ];

        return $this;
    }
1056687
public function sort($attribute, $direction = SORT_ASC)
    {
        if ($direction === SORT_DESC) {
            $attribute = '-' . $attribute;
        }

        if ($this->offsetExists('sort')) {
            $attribute = $this->offsetGet('sort') . ',' . $attribute;
        }

        $this->offsetSet('sort', $attribute);

        return $this;
    }
1336908
public function addOrderByField($field = 'order', $direction_desc = false, $table = '', $do_not_use_table_in_sql = false): self
    {
        // No table provided
        if (!$table) {
            $table = $this->getDbTableName();
        }

        $direction = $direction_desc ? 'DESC' : ' ASC';

        // Swap fields with translation table
        if (\in_array($field, $this->translation_fields, true)) {
            $this->translation_join_count++;
            $this->addJoinTable(['cms_translations', $this->getTranslationTableJoinAlias() . $this->translation_join_count], 'id', $field, 'LEFT', $table);

            $this->order_fields[] = [
                'table'                   => false,
                'field'                   => '`' . $this->getTranslationTableJoinAlias() . $this->translation_join_count . '`.`' . $this->getLanguage() . '`',
                'direction'               => $direction,
                'do_not_use_table_in_sql' => true,
                'type'                    => 'string'
            ];
        } else {
            $this->order_fields[] = [
                'table'                   => $table,
                'field'                   => $field,
                'direction'               => $direction,
                'do_not_use_table_in_sql' => $do_not_use_table_in_sql,
                'type'                    => 'simple'
            ];
        }

        return $this;
    }
493180
public function sortBy($field, $direction = 'asc', $flags = null)
    {
        $this->sortByField = $field;

        // Normalize direction.
        $direction = strtolower($direction);

        if ($direction === 'asc' || $direction === 'desc') {
            $this->sortByDirection = $direction;
        }

        if (is_null($flags)) {
            $this->sortByFlags = SORT_NATURAL + SORT_FLAG_CASE;
        }

        return $this;
    }
320577
public function setOrder(string $order, string $direction): self
    {
        return $this->setParam('order', [$order => $direction]);
    }
1255621
public function sortByDimensionValue($direction)
    {
        if ($this->id != '$value') {
            throw new AnalyticsDbException('In order to sort by dimension value, you need to first group by dimension value.');
        }

        $direction = (int)$direction;

        $this->pipeline['$sort'] = ['_id.value' => $direction];


        return $this;
    }