Logic::sort()

@return
351908
protected function sort()
    {
        $orderBy = $this->orderBy;
        $sortBy  = $this->sortBy;

        if ($orderBy=='')
            return false;
        usort($this->documents, function($a, $b) use ($orderBy, $sortBy) {
            $propA = $a->field($orderBy);
            $propB = $b->field($orderBy);
            if (strnatcasecmp($propB, $propA) == strnatcasecmp($propA, $propB)) {
                return 0;
            }
            if ($sortBy == 'DESC')
                return (strnatcasecmp($propB, $propA) < strnatcasecmp($propA, $propB)) ? -1 : 1;
            else
                return (strnatcasecmp($propA, $propB) < strnatcasecmp($propB, $propA)) ? -1 : 1;
        });
    }
816435
public function orderByCreatedAt($sort = SORT_ASC)
    {
        /* @var $this ActiveQuery */
        $model = $this->noInitModel;
        if (!is_string($model->createdAtAttribute) || empty($model->createdAtAttribute)) {
            return $this;
        }
        return $this->addOrderBy([$model->createdAtAttribute => $sort]);
    }
212069
public function sort()
    {
        if ($this->sortedPackages === null) {
            $this->sortedPackages = [];
            reset($this->unsortedPackages);
            while (!empty($this->unsortedPackages)) {
                $resolved = $this->sortPackage(key($this->unsortedPackages));
                if ($resolved) {
                    reset($this->unsortedPackages);
                } else {
                    next($this->unsortedPackages);
                }
            }
        }

        return $this->sortedPackages;
    }
293190
public function sortByStartDate()
	{
		uksort( $this->contexts, function( $a, $b ) use ( &$contexts )
		{
			return -1 * strcmp( $this->contexts[ $a] ['period']['startDate'], $this->contexts[ $b]['period']['startDate'] );
		} );

		return $this;
	}
927679
public function getSorting()
    {
        $sortOrder = $this->getRequest()->get('sortOrder', 'asc');
        $sortBy = $this->getRequest()->get('sortBy', 'id');

        return [$sortBy => $sortOrder];
    }
145831
public function sortByNameDesc()
    {
        $this->sort(
            function (SplFileInfo $a, SplFileInfo $b) {
                return strcmp($b->getRealpath(), $a->getRealpath());
            }
        );
        return $this;
    }
608796
public function sortByDependencies() : self
    {
        /** @var $packages Package[] */
        $packages = $this->packages;
        $sortedPackages = [];

        while (!empty($packages)) {
            foreach ($packages as $packageName => $package) {
                $dependentPackages = $package->getDependencies()->toArray();
                if (empty(array_diff_key($dependentPackages, $sortedPackages))) {
                    // all of this packages dependencies are already in the sorted array, so it can be appended
                    $sortedPackages[$packageName] = $package;
                    unset($packages[$packageName]);
                    continue(2);
                }
            }
            throw new \LogicException('Packages have circular dependencies');
        }

        return new static($sortedPackages);
    }
1174180
private function getSort()
    {
        if ($sort = Utils::findKey($this->options, 'sort', false))
        {
            $this->payload['sort'] = $sort;
        }
    }
647867
protected function parseSort($sort)
    {
        $type = substr($sort, 0, 1);
        $key = substr($sort, 1);

        switch ($type) {
            case '+': $type = Sort::TYPE_ASC; break;
            case '-': $type = Sort::TYPE_DESC; break;
            default:
                throw new NoSuchSortException();
        }

        return new Sort($type, $key);
    }
1192698
public function sortByValue($sort = SORT_NUMERIC)
    {
        return $this
            ->groupBy(function (Card $card) {
                return $card->value();
            })
            ->map(function (CardCollection $valueGroup) {
                return $valueGroup->sortBySuitValue();
            })
            ->flatten()
            ->sortBy(function (Card $card) {
                return $card->value();
            }, $sort)
            ->values();
    }
469192
public function sort()
    {
        usort(
            $this->items,
            function ($a, $b) {
                if ($a[0] === $b[0]) {
                    return 0;
                }
                return $a[0] < $b[0] ? -1 : 1;
            }
        );
    }
1015571
private function sort()
    {
        if (!$this->sorted) {
            $this->sorted = true;
            return usort($this->requestRates, function (array $requestRateA, array $requestRateB) {
                // PHP 7: Switch to the <=> "Spaceship" operator
                return $requestRateB['rate'] > $requestRateA['rate'];
            });
        }
        return $this->sorted;
    }
806473
public function getSorts()
    {
        $sortInput = $this->request->input($this->sortName, '');

        $sortFields = $this->collection->make(
            is_array($sortInput) ? $sortInput :
                explode($this->sortFieldsSeparator, $sortInput));

        $sorts = $this->collection->make();

        $sortFields->each(function ($field) use ($sorts) {
            $s = new Sort();
            $order = 'ASC';

            if (starts_with($field, $this->sortDescSign)) {
                $order = 'DESC';
                $field = mb_substr($field, mb_strlen($this->sortDescSign));
            }

            if ($field = trim($field)) {
                $s->setField($field);
                $s->setOrder($order);
                $sorts->put($field, $s);
            }
        });

        return $sorts->values();
    }
1135389
public function sort(Sorting $sorting)
	{
		if (is_callable($sorting->getSortCallback())) {
			call_user_func(
				$sorting->getSortCallback(),
				$this->data_source,
				$sorting->getSort()
			);

			return $this;
		}

		$sort = $sorting->getSort();

		if (!empty($sort)) {
			foreach ($sort as $column => $order) {
				$this->data_source->addOrderBy($this->checkAliases($column), $order);
			}
		} else {
			/**
			 * Has the statement already a order by clause?
			 */
			if (!$this->data_source->getDQLPart('orderBy')) {
				$this->data_source->orderBy($this->checkAliases($this->primary_key));
			}
		}

		return $this;
	}
524292
protected function sort($order)
    {
        $ordered = [];

        $matrix = [
            'label'     => 'getLabels',
            'component' => 'getComponents',
            'message'   => 'getMessage',
        ];

        foreach ($order as $identifier) {
            $components = $this->{$matrix[$identifier]}();
            foreach ($components as $component) {
                $index                              = count($ordered);
                $this->indexReverse[$identifier][0] = $index;
                $this->index[$index]                = $identifier;
                $ordered[]                          = $component;
            }
        }

        return $ordered;
    }
85947
private function sort()
    {
        if (!$this->sorted) {
            $this->sorted = true;
            return usort($this->visitTimes, function (array $visitTimeA, array $visitTimeB) {
                // PHP 7: Switch to the <=> "Spaceship" operator
                return $visitTimeA['from'] > $visitTimeB['from'];
            });
        }
        return $this->sorted;
    }
449871
public function sort($data){

            $count = count($data);

            if($count <= 1) return $data;

            $left = $right = [];

            return $sorted;

        }