Sets default sorting.
@param array $sort
@return Grid
@throws Exception
513245
public function setDefaultSort(array $sort)
    {
        static $replace = ['asc' => Column::ORDER_ASC, 'desc' => Column::ORDER_DESC];

        foreach ($sort as $column => $dir) {
            $dir = strtr(strtolower($dir), $replace);
            if (!in_array($dir, $replace)) {
                throw new Exception("Dir '$dir' for column '$column' is not allowed.");
            }

            $this->defaultSort[$column] = $dir;
        }

        return $this;
    }
780293
public function setOrder($order)
    {
        $pool = ['asc', 'desc'];

        // Silently ignore wrong values
        if (in_array($order, $pool)) {
            $this->container['order'] = $order;
        }

        return $this;
    }
90373
protected function setSorts(Jory $jory): void
    {
        $sorts = $this->getArrayValue($this->joryArray, 'srt');

        if ($sorts) {
            foreach ($sorts as $sort) {
                $order = 'asc';
                if (substr($sort, 0, 1) === '-') {
                    $order = 'desc';
                    $sort = substr($sort, 1);
                }
                try {
                    $jory->addSort(new Sort($sort, $order));
                } catch (JoryException $e) {
                    // This exception cannot be thrown here because we checked the data.
                    // Use empty try/catch to prevent IDE suggesting we should use a @throws tag.
                }
            }
        }
    }
731978
public function sort($order = 'asc')
    {
        if ($order == 'desc') {
            rsort($this->_map);
        }else{
            sort($this->_map);
        }

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

        return $this;
    }
967264
public function setOrderBy($sort, $direction = 'ASC')
    {
        $this->sort = $sort;
        $this->direction = $direction;
        return $this;
    }
1014189
public function andSort(Sort $sort = null) : Sort
    {
        if ($sort === null) {
            return $this;
        }
        $orders = $this->orders;
        foreach ($sort as $order) {
            $orders[] = $order;
        }
        return new Sort($orders);
    }
286724
protected function setSortOrder($arguments)
    {
        $sortString = '';
        if (!empty($arguments['sort'])) {
            $sortString = $arguments['sort'];
        } else {
            if (!empty($this->settings['sort'])) {
                foreach ($this->settings['sort'] as $sortSetting) {
                    if ('default' === $sortSetting['id']) {
                        $sortString = $sortSetting['sortCriteria'];
                        break;
                    }
                }
            }
        }

        $this->addSortStringForQuery($sortString);
        $this->addSortOrdersToTemplate($arguments);
    }
1031421
public function setColumnsOrder($order)
	{
		$new_order = [];

		foreach ($order as $key) {
			if (isset($this->columns[$key])) {
				$new_order[$key] = $this->columns[$key];
			}
		}

		if (sizeof($new_order) === sizeof($this->columns)) {
			$this->columns = $new_order;
		} else {
			throw new DataGridException('When changing columns order, you have to specify all columns');
		}

		return $this;
	}
1115097
public function set( $key, $value, $sort = TRUE )
	{
		if( empty( $key ) )																		//  no Key given
			throw new InvalidArgumentException( 'Key must not be empty.' );						//  throw Exception
		if( is_array( $value ) )																//  Pair Map given
			foreach( $value as $pairKey => $pairValue )											//  iterate given Pair Map
				$this->pairs[$key.$this->divider.$pairKey]	= $pairValue;						//  add Pair to stores Pairs
		else																					//  single Value given
			$this->pairs[$key]	= $value;														//  set Pair
		if( $sort )																				//  sort after Insertion is active
			ksort( $this->pairs );																//  sort stored Pairs by Keys
	}
107183
protected function setSortingOrder()
    {
        if (null !== $this->info->list->default_sort) {
            return $this;
        }

        if ($this->info->list->orderable && $this->info->list->getOrderableColumn()) {
            $this->info->list->default_sort = $this->info->list->getOrderableColumn();
        } elseif ($this->info->timestamps) {
            $this->info->list->default_sort = $this->info->timestamp_created;
        } elseif ($this->info->incrementing) {
            $this->info->list->default_sort = $this->model->getKeyName();
        }

        return $this;
    }
1144812
public function setDefaultData(array $data)
    {
        foreach ($data as $key => $val) {
            $this->defaultData[$key] = $val;
        }

        return $this;
    }
130758
public function setDefaultsort($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->defaultsort !== $v) {
            $this->defaultsort = $v;
            $this->modifiedColumns[PageTableMap::COL_DEFAULTSORT] = true;
        }

        return $this;
    }
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;
	}
291227
public function setSortByColumnOrder($order)
    {
        switch ($order) {
            case 'desc':
                $this->sortByColumnOrder = self::SORT_ORDER_DESC;
                break;
            case 'asc':
                $this->sortByColumnOrder = self:: SORT_ORDER_ASC;
                break;
        }

        return $this;
    }
1326470
public function setSort($sort)
    {
        $this->reordered = $this->sort !== $sort;
        $this->sort = $sort;

        return $this;
    }
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;
	}