排序 支持 ['timefile'=>'desc','name'=>asc] 或者直接 order("time desc","name asc")

@param $field

@return $this
968148
public function order($field) {
        $order = [];
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $order[] = $key . ' ' . $value;
            }
        } else {
            $order = func_get_args();
        }
        $order = implode(',', $order);
        $this->order = !empty($order) ? ' ORDER BY ' . $order : '';
        return $this;
    }
1211957
public function setDescriptor($field, $order = 'ASC')
    {
        // Define Attributes:
        
        $this->setTextField($field);
        $this->setSearchFields([$field]);
        $this->setSortBy([$field => $order]);
        
        // Answer Self:
        
        return $this;
    }
808874
public function orderBy($field, $dir = 'ASC')
    {
        if (!$this->oosql_multiFlag) {
            $this->oosql_order = ' ORDER BY ' . $field . ' ' . $dir;
        }
        return $this;
    }
1166247
public function setSort($fieldName, $order = 'asc'): self
    {
        if (null !== $fieldName) {
            $sort = [];
            $fields = is_array($fieldName) ? $fieldName : [$fieldName => $order];

            foreach ($fields as $fieldName => $order) {
                $sort[] = [$fieldName => $order];
            }
        } else {
            $sort = null;
        }

        $this->sort = $sort;

        return $this;
    }
211801
public function removeField($field)
    {
        foreach ($this->fieldsets as $fieldset) {
            if ($fieldset->hasField($field)) {
                unset($fieldset[$field]);
            }
        }
        return $this;
    }
415785
public function setSort($field,$sort = false)
    {
        $this->sort_field = $field;
        $this->sort_state = $sort;
        return $this;
    }
970804
public function orderBy($field, $direction = 'asc')
    {
        $this->setOrderByField($field);
        $this->setOrderByDirection($direction);

        return $this;
    }
452677
public function order($fields = null)
    {
        if (!$fields) {
            return $this;
        }
        if ($fields = is_array($fields) ? $fields : func_get_args()) {
            $this->_parts['order'] = array_merge($this->_parts['order'], $this->_order($fields));
        }
        return $this;
    }
907535
public function desc($fields) {
        if (is_array($fields)) {
            $this->_order = ' ORDER BY ' . implode($fields, ', ') . ' DESC';
        } else {
            $this->_order = ' ORDER BY ' . $fields . ' DESC';
        }
         
        return $this;
    }
531792
public function sort($fields)
    {
        $fields = $this->unitOfWork
            ->getDocumentPersister($this->class->name)
            ->prepareSortOrProjection($fields);

        $this->baseCursor->sort($fields);
        return $this;
    }
1046501
public static function formatField(Field $field)
    {
        $timestamp = $field->value ? $field->value->getTimestamp() : 0;

        return DateToolbox::formatDate($field->view_mode_settings['format'], $timestamp);
    }
854639
public function orderBy($field, $direction = 'asc')
    {
        $this->sort = $field;
        $this->sortDirection = $direction;

        return $this;
    }
1245481
public static Sort sort(String field, boolean asc) {
        Sort s = new Sort(false);
        s.add(field, asc ? "$asc" : "$desc");
        return s;
    }
1167432
public function sort($fields)
    {
        foreach ($fields as $fieldName => $order) {
            if (is_string($order)) {
                $order = strtolower($order) === 'asc' ? 1 : -1;
            }

            if (is_scalar($order)) {
                $fields[$fieldName] = (integer) $order;
            }
        }
        $this->sort = $fields;
        $this->riakCursor->sort($fields);
        return $this;
    }
724708
public function setSort($sort, $field = null)
    {
        $param = $this->buildParam('facet.sort', $field);
        return $this->set($param, $sort);
    }
494492
protected function _order($fields)
    {
        $direction = 'ASC';

        $result = [];
        foreach ($fields as $field => $value) {
            if (!is_int($field)) {
                $result[$field] = $value;
                continue;
            }
            if (preg_match('/^(.*?)\s+((?:a|de)sc)$/i', $value, $match)) {
                $value = $match[1];
                $dir = $match[2];
            } else {
                $dir = $direction;
            }
            $result[$value] = $dir;
        }
        return $result;
    }
8414
public function sortBy(string $field, string $direction = 'asc'): self
    {
        $this->sortBy = [$field, $direction];

        return $this;
    }