Sorts the LDAP search results by the specified field and direction.

@param string   $field
@param string   $direction
@param int|null $flags

@return Builder
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;
    }
1002420
public function sorts($sorts, $direction = self::SORT_DESC) {
		foreach($sorts as $sort) {
			$this->sort($sort, $direction);
		}
		return $this;
	}
862619
public function sortField($field, $direction = SORT_ASC, $sortFlag = SORT_NUMERIC)
    {
        // check array
        if (!$this->isArray($this->first()->val())) {
            throw new ArrayObjectException(ArrayObjectException::MSG_MULTIDIM_SORT);
        }

        // check if key is present in the array
        if (!$this->first()->key($field)) {
            throw new ArrayObjectException(ArrayObjectException::MSG_VALUE_NOT_PRESENT, [
                '$field',
                'the current array'
            ]);
        }

        // do the sorting
        $tempArray = array();
        $thisArray = $this->val();

        foreach ($thisArray as $mk => $m) {
            $tempArray[$m[$field]][] = $mk;
        }

        if ($direction == SORT_DESC) {
            krsort($tempArray, $sortFlag);
        } else {
            ksort($tempArray, $sortFlag);
        }

        $newArray = array();
        foreach ($tempArray as $tk => $tv) {
            foreach ($tv as $ttk => $ttv) {
                $newArray[$ttv] = $thisArray[$ttv];
            }
        }

        $this->val($newArray);
        unset($tempArray);
        unset($thisArray);

        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);
    }
539768
public function sort(array $fields)
	{
		$sortFields = [];
		foreach ($fields as $field => $value) {
			// Simplest form, just a field name.
			if (is_numeric($field) && !is_array($value)) {
				$sortFields[] = $value;
			} // Field with direction and/or other options.
			else {
				$sortFields[] = [$field => $value];
			}
		}

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

		return $this;
	}
689108
public function orderBy($column, $direction = 'asc')
	{
		$direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';

		$this->orders[] = compact('column', 'direction');

		return $this;
	}
543419
public function sortAction($id, $direction)
    {
        $entity = $this->getRepository()->sort($id, $direction);

        $last = $this->getRequest()->headers->get('referer');

        return $this->redirect($last);
    }
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;
    }
914130
private Sort withDirection(final Direction direction) {

    return Sort.by(orders.stream().map(it -> new Order(direction, it.getProperty()))
        .collect(Collectors.toList()));
  }
110291
public function orderBy($key, $direction = \Parable\ORM\Query::ORDER_ASC)
    {
        $this->orderBy = ['key' => $key, 'direction' => $direction];
        return $this;
    }
1016576
public function sortBy($field, $options = SORT_REGULAR, $descending = false)
    {
        $results = [];

        foreach ($this->divisions as $key => $value) {
            $meta = $value->toArray();
            $results[$key] = $meta[$field];
        }

        $descending ? arsort($results, $options)
                    : asort($results, $options);
        
        foreach (array_keys($results) as $key) {
            $results[$key] = $this->divisions[$key];
        }

        return new static($this->manager, $results);
    }
970804
public function orderBy($field, $direction = 'asc')
    {
        $this->setOrderByField($field);
        $this->setOrderByDirection($direction);

        return $this;
    }
637591
public function sortByProperty( $property, $direction = null )
    {
        $this->sort( $this->generateSortByPropertyClosure( $property, $direction ) );
        return $this;
    }
738767
public function sort($str_field, $str_direction = self::DESC)
    {
        $this->arr_sorts[] = [$str_field, $str_direction];
        return $this;
    }
144551
public function scopeSortedBySourceAttribute(Builder $query, $attribute, $direction = 'ASC')
    {
        return $this->orderQueryBySourceAttribute($query, $attribute, $direction);
    }
864691
public function getTodoURL($todo=NULL, $flags = 0x000000) {
    return $this->getURL($this->getTodoQueryVars($todo),$flags);
  }
45489
public function groupBy($fields, $direction = false)
    {
        $this->groupBy->addFields($fields, $direction);

        return $this;
    }