设置sort
@access public
@param array|string|object   $field
@param string                $order
@return $this
765418
public function order($field, $order = '')
    {
        if (is_array($field)) {
            $this->options['sort'] = $field;
        } else {
            $this->options['sort'][$field] = 'asc' == strtolower($order) ? 1 : -1;
        }
        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;
	}
1080198
public function getFieldByOrder($order)
    {
        foreach ($this->_fields as $field) {
            if ($field instanceof FieldInterface) {
                if ($field->getOrder() == $order) {
                    return $field;
                }
            }
        }

        return null;
    }
503697
public function addOrderBy($field, $order = 'ASC')
    {
        $alias = self::DEFAULT_TABLE_ALIAS;
        if (strpos($field, '.') > 0) {
            //monta os joins
            $newAliasField = $this->associationQueryFields($field);
            $alias = $newAliasField['alias'];
            $field = $newAliasField['field'];
        }
        $this->queryBuilder->addOrderBy($this->getFullFieldName($field, $alias), $order);

        return $this;
    }
951994
public function setOrder(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Order $order = null)
    {
        $this->order = $order;

        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;
    }
2310
public function byFunction(
        string $function,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FUNCTION,
            'function' => $function,
            'order' => $order,
        ];

        return $this;
    }
683036
public function sortBy($fields, $order = null, array $parameters = [])
    {
        $fields = is_array($fields) ? $fields : [$fields];

        foreach ($fields as $field) {
            $sort = new FieldSort($field, $order, $parameters);

            $this->query->addSort($sort);
        }

        return $this;
    }
1250855
public function order($order)
    {
        $order = $this->prepareNames(func_get_args(),false);
        $this->order = $order;
        return $this;
    }
4965
public function setOrder($order_field, $order_type)
    {
        $this->order_field = $order_field;
        $this->order_type  = $order_type;
        $this->queryBuilder->orderBy($order_field, $order_type);
        return $this;
    }
808874
public function orderBy($field, $dir = 'ASC')
    {
        if (!$this->oosql_multiFlag) {
            $this->oosql_order = ' ORDER BY ' . $field . ' ' . $dir;
        }
        return $this;
    }
715873
public function setOrder($order)
    {
        if (! is_array($order)) {
            $order = func_get_args();
        }

        $this->order = $order;

        return $this;
    }
1210752
public function orderBy($columns, string $order = 'ASC')
	{
		$this->orderings[] =
		[
			'column' => is_array($columns) ? $columns : [$columns],
			'order'  => ($order === 'ASC' || $order === 'asc') ? 'ASC' : 'DESC',
		];

		return $this;
	}
1268991
public function orderBy($field, $order)
    {
        if (!in_array($field, $this->getAvailableFields())) {
            throw new \InvalidArgumentException(sprintf('Field "%s" not supported, prefer: %s', $field, implode(', ', $this->getAvailableFields())));
        }

        if (!in_array($order, array('ASC', 'DESC'))) {
            throw new \InvalidArgumentException(sprintf('Order "%s" not supported, prefer: ASC or DESC', $order));
        }

        $this->sort = array($field, $order);

        return $this;
    }
924031
public function addSorting($sort, $order = SearchQuery::SORT_ASC)
    {
        $this->searchQuery->addSorting($sort, $order);

        return $this;
    }
725962
public function order($field, $order = null)
    {
        if (!empty($field)) {
            if (is_string($field)) {
                if (!empty($this->options['via'])) {
                    $field = $this->options['via'] . '.' . $field;
                }
                $field = empty($order) ? $field : [$field => $order];
            } elseif (!empty($this->options['via'])) {
                foreach ($field as $key => $val) {
                    if (is_numeric($key)) {
                        $field[$key] = $this->options['via'] . '.' . $val;
                    } else {
                        $field[$this->options['via'] . '.' . $key] = $val;
                        unset($field[$key]);
                    }
                }
            }
            if (!isset($this->options['order'])) {
                $this->options['order'] = [];
            }
            if (is_array($field)) {
                $this->options['order'] = array_merge($this->options['order'], $field);
            } else {
                $this->options['order'][] = $field;
            }
        }
        return $this;
    }
1103826
public function sortBy($array, $field, $order = 'ASC')
    {
        if ($array instanceof Collection) {
            $array = $array->toArray();
        }
        if (1 >= count($array)) {
            return $array;
        }

        usort(
            $array,
            function ($firstElement, $secondElement) use ($field, $order) {
                $accessor = PropertyAccess::createPropertyAccessor();

                $firstProperty = (string)$accessor->getValue($firstElement, $field);
                $secondProperty = (string)$accessor->getValue($secondElement, $field);

                $result = strcasecmp($firstProperty, $secondProperty);
                if ('DESC' === $order) {
                    $result *= -1;
                }

                return $result;
            }
        );

        return $array;
    }