Factory method to order by several properties with the same direction.

@param array $properties
@param Direction $direction
@return Sort
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);
    }
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;
    }
1274904
protected function sortBy($field, $direction) {

        if (!in_array($direction, [DoplioDbTable::SORT_ASC, DoplioDbTable::SORT_DESC])) {
            throw new \InvalidArgumentException(sprintf('%s is an invalid sort direction'), $direction);
        }

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

        return $this;
    }
1311603
public function orderBy($field, $direction = self::DESC) {
        if (is_array($field)) {
            foreach ($field as $key => $dir) {
                $this->orderBy($key, $dir);
            }

        } else if ($field === 'RAND') {
            $this->_orderBy[] = $this->func('RAND');

        } else if ($field instanceof Func) {
            $this->_orderBy[] = $field;

        } else {
            $direction = strtolower($direction);

            if ($direction != self::ASC && $direction != self::DESC) {
                throw new InvalidArgumentException(sprintf('Invalid order direction %s for field %s', $direction, $field));
            }

            $this->_orderBy[$field] = $direction;
        }

        return $this;
    }
358857
function orderBy( $column, $direction = "ASC" ) {

        $clone = clone $this;

        if ($direction===true) {
            $clone->orderBy[] = $column;
        }else{
            $clone->orderBy[] = $this->db->quoteIdentifier( $column ) . " " . $direction;
        }

        return $clone;

    }
1239861
public function sortBy($fieldName, $direction = null)
	{
		$predefinedFields = $this->get('sort');
		$sortingFields = [];

		// Field exists, prioritize and set direction (if any).
		if ($field = $this->findField($fieldName, $predefinedFields)) {
			// Field was defined without options.
			if (!is_array($field)) {
				if ($direction) {
					$sortingFields[] = [$fieldName => $direction];
				} else {
					$sortingFields[] = $fieldName;
				}
			} else {
				// Set direction, otherwise it will just use the default definition.
				if ($direction) {
					// Defined as {"post_date" : {"order" : "asc", "mode": "avg"}}
					if (is_array($field[$fieldName])) {
						$field[$fieldName]['order'] = $direction;
					} // Defined as {"post_date" : "asc"}
					else {
						$field[$fieldName] = $direction;
					}
				}
				$sortingFields[] = $field;
			}
		} // Field does not exist, add it.
		else {
			$sortingFields[] = [$fieldName => $direction];
		}

		// Add the predefined fields but remove the one we are sorting on.
		if ($predefinedFields) {
			foreach ($predefinedFields as $field) {
				if (!is_array($field) && $fieldName == $field) {
					continue;
				} elseif (is_array($field) && array_key_exists($fieldName, $field)) {
					continue;
				}

				$sortingFields[] = $field;
			}
		}

		$this->set('sort', $sortingFields);

		return $this;
	}
207124
public function orderBy($key, $direction = 'ASC')
    {
        if (Helpers\Validate::table($this->name)->field($key))
        {
            $directions                        = array(
                'ASC'  => SORT_ASC,
                'DESC' => SORT_DESC
            );
            $this->pending[__FUNCTION__][$key] = isset($directions[$direction]) ? $directions[$direction] : 'ASC';
        }

        return $this;
    }
482727
public function sort($element, $direction)
    {
        // simple sorting
        if (in_array($element, $sortable = app('scaffold.module')->sortable(), true)) {
            if ($table = app('scaffold.module')->model()->getTable()) {
                $element = "{$table}.{$element}";
            }

            $this->query->orderBy($element, $direction);
        }

        if (array_key_exists($element, $sortable) && is_callable($callback = $sortable[$element])) {
            $this->query = call_user_func_array($callback, [$this->query, $element, $direction]);
        }

        if (array_key_exists($element, $sortable) && is_string($handler = $sortable[$element])) {
            $handler = new $handler($this->query, $element, $direction);
            if (!$handler instanceof QueryBuilder || !method_exists($handler, 'build')) {
                throw new \Exception('Handler class must implement '.QueryBuilder::class.' contract');
            }
            $this->query = $handler->build();
        }

        return $this;
    }
77129
public function orderBy($column, $direction = 'ASC')
    {
        $this->ordering[$this->applyTableAlias($column)] = $direction;

        return $this;
    }
456469
public function orderBy($fields, string $direction = 'ASC'): IQueryBuilderHandler
    {
        if (\is_array($fields) === false) {
            $fields = [$fields];
        }

        foreach ((array)$fields as $key => $value) {
            $field = $key;
            $type = $value;

            if (\is_int($key) === true) {
                $field = $value;
                $type = $direction;
            }

            if (($field instanceof Raw) === false) {
                $field = $this->addTablePrefix($field);
            }

            $this->statements['orderBys'][] = compact('field', 'type');
        }

        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;
    }
1294824
public function orderBy($orderBy, $direction='asc')
    {
        if($direction == 'desc')
            return $this->model->orderBy($orderBy, 'desc');
        else
            return $this->model->orderBy($orderBy, 'asc');
    }
914130
private Sort withDirection(final Direction direction) {

    return Sort.by(orders.stream().map(it -> new Order(direction, it.getProperty()))
        .collect(Collectors.toList()));
  }
42929
public function orderBy($column, $direction = 'asc')
    {
        $property = $this->unions ? 'unionOrders' : 'orders';

        $direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';

        $this->{$property}[] = compact('column', 'direction');

        return $this;
    }
940748
public static PropertyOrder.Builder makeOrder(String property,
      PropertyOrder.Direction direction) {
    return PropertyOrder.newBuilder()
        .setProperty(makePropertyReference(property))
        .setDirection(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;
    }