Sort data
@param  Sorting $sorting
@return static
545303
public function sort(Sorting $sorting)
	{
		if (is_callable($sorting->getSortCallback())) {
			$data = call_user_func(
				$sorting->getSortCallback(),
				$this->data,
				$sorting->getSort()
			);

			if (!is_array($data)) {
				throw new DataGridArrayDataSourceException('Sorting callback has to return array');
			}

			$this->setData($data);

			return $this;
		}

		$sort = $sorting->getSort();

		foreach ($sort as $column => $order) {
			$data = [];

			foreach ($this->data as $item) {
				if (is_object($item[$column]) && $item[$column] instanceof \DateTimeInterface) {
					$sort_by = $item[$column]->format('Y-m-d H:i:s');
				} else {
					$sort_by = (string) $item[$column];
				}
				$data[$sort_by][] = $item;
			}

			if ($order === 'ASC') {
				ksort($data);
			} else {
				krsort($data);
			}

			$data_source = [];

			foreach ($data as $i) {
				foreach ($i as $item) {
					$data_source[] = $item;
				}
			}

			$this->setData($data_source);
		}

		return $this;
	}
1114219
public function orderBy($sort, $order = 'ASC') {
        if ($order == 'ASC' || $order == 'DESC') {
            $this->q->apd(' ORDER BY ' . $sort . ' ' .$order);
        } else {
            $this->setError('q', 'No valid order');
            return false;
        }

        return $this;
    }
52359
public function sort($sort)
    {
        if (null !== $sort && !is_array($sort)) {
            throw new \InvalidArgumentException(sprintf('The sort "%s" is not valid.', $sort));
        }

        $this->sort = $sort;

        return $this;
    }
1185772
function sort(bool $descending = false, int $options = \SORT_REGULAR) {
        $args = $this->baseStorageArgs;
        $args[] = parent::sort($descending, $options)->all();
        
        return (new static(...$args));
    }
1247363
protected function sort(array &$files, $sort, $order)
    {
        $sorters = $this->getSorters();

        if (isset($sorters[$sort]['handlers']['sort'])) {
            $function = $sorters[$sort]['handlers']['sort'];
            // Suppress errors, see https://bugs.php.net/bug.php?id=50688
            @uasort($files, function ($a, $b) use ($function, $order) {
                return $function($a, $b, $order);
            });
        }
    }
244900
public function sort($sSorting)
    {
        //Get sorting list
        $arResultIDList = PromoBlockListStore::instance()->sorting->get($sSorting);

        return $this->applySorting($arResultIDList);
    }
939900
public static function sort(array $data, $condition, $descending = false, $options = SORT_REGULAR)
    {
        $results = [];

        // If condition is string, we just use this as key name to get sort data from items.
        $callback = is_callable($condition) ? $condition : function ($item) use ($condition) {
            // We don't know child item is array or object, use getter to get it.
            return static::get($item, $condition);
        };

        // Loop items to get sorting conditions with defined in callback.
        foreach ($data as $key => $value) {
            $results[$key] = $callback($value, $key);
        }

        // Do sort
        $descending ? arsort($results, $options) : asort($results, $options);

        // Get origin data from items
        foreach ($results as $key => $value) {
            $results[$key] = $data[$key];
        }

        return $results;
    }
541003
private function parseSort(array $sort)
    {
        $out = '';
        if (!empty($sort)) {
            $conditions = [];
            foreach ($sort as $field => $direction) {
                $direction = $direction ? 'DESC' : 'ASC';
                $conditions[] = sprintf('%s %s', $field, $direction);
            }
            $out = sprintf(' ORDER BY %s', implode(', ', $conditions));
        }
        return $out;
    }
27081
public function sort($sorts)
    {
        usort($this->rows, 
            function ($a, $b) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $sort => $direction) {
                    if (is_string($direction)) {
                        $cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ? 
                            $a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
                        $cmp = $direction === 'asc' ? $cmp : - $cmp;
                    } else if (is_callable($direction)) {
                        $cmp = $direction($a[$sort], $b[$sort]);
                    }
                    if ($cmp !== 0) {
                        break;
                    }
                }
                return $cmp;
            }
        );
        return $this;
    }
1074892
public function sort()
	{
		usort($this->allEvents, function ($event1, $event2) {
			if ($event1->getStartDate() == $event2->getStartDate()) {
				return $event1->getId() < $event2->getId() ? -1 : 1;
			}

			return $event1->getStartDate() < $event2->getStartDate() ? -1 : 1;
		});

		return $this;
	}
8218
@CheckResult
    @NonNull
    public final Data<T> sort(@NonNull Comparator<? super T> comparator) {
        return new SortData<>(this, comparator);
    }
361561
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 = $this->data_source->orderBy($this->prepareColumn($column), $order);
			}
		} else {
			/**
			 * Has the statement already a order by clause?
			 */
			$order = $this->data_source->getQueryBuilder()->getClause('order');

			if (ArraysHelper::testEmpty($order)) {
				$this->data_source = $this->data_source->orderBy($this->prepareColumn($this->primary_key));
			}
		}

		return $this;
	}
679244
public static function ksort($data)
    {
        if (static::isArray($data) ) {
            foreach ( $data as &$v ) {
                if (is_array($v)) {
                    $v = static::ksort($v);
                }
            }
        }

        ksort($data);

        return $data;
    }
642639
public function addSort($sort)
    {
        if (!$this->sorts->contains($sort)) {
            $this->sorts[] = $sort;
        }

        return $this;
    }
383028
public function orderBy(string $sort, string $order = 'ASC'): self
    {
        $order = 'ASC' === strtoupper($order) ? 'ASC' : 'DESC';
        $this->orderBy = [$sort => $order];
        return $this;
    }
304131
public function sort($data){

            $rule = call_user_func($this->rule);
            if($rule === "desc"){
                arsort($data, SORT_NATURAL);
            }else{
                asort($data, SORT_NATURAL);
            }

            return $data;

        }
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]);
    }