Turn an array of sort objects into an array.

@param array $sorts
@return array
977089
protected function getSortsArray(array $sorts): array
    {
        $sortsArray = [];
        foreach ($sorts as $sort) {
            $sortsArray[] = ($sort->getOrder() === 'desc' ? '-' : '') . $sort->getField();
        }

        return $sortsArray;
    }
30780
private function getValidatedSorts(iterable $sortsFromParent): iterable
    {
        $ruleIndexes = $this->serializerClass::readSortsRuleIndexes($this->getSerializedRuleSet());

        if ($ruleIndexes === null) {
            // without validation
            foreach ($sortsFromParent as $field => $isAsc) {
                yield $field => $isAsc;
            }
        } else {
            // with validation
            $ruleIndex = $this->serializerClass::readRuleMainIndex($ruleIndexes);
            $this->validationStarts(static::PARAM_SORT, $ruleIndexes);
            foreach ($sortsFromParent as $field => $isAsc) {
                $this->getCaptures()->clear();
                $this->validateAndAccumulateError($field, $ruleIndex);
                if ($this->getCaptures()->count() > 0) {
                    yield $this->readSingleCapturedValue() => $isAsc;
                }
            }
            $this->validateEnds(static::PARAM_SORT, $ruleIndexes);
        }
    }
725407
public function normalizeArray($array, $sort = true) {
        $output = array();

        if ($array) {
            foreach ($array as $key => $value) {
                if (is_numeric($key)) {
                    $output[] = $value;
                } else {
                    $output[] = $key;
                }
            }

            if ($sort) {
                sort($output);
            }
        }

        return $output;
    }
1221671
private function sortItems($items)
    {
        $ids = [];
        $positions = [];
        $index = 0;
        foreach ($items as $item) {
            if (!array_key_exists($item['type'], $ids)) {
                $ids[$item['type']] = [];
            }
            $ids[$item['type']][] = $item['id'];
            $positions[sprintf('%s;%s', $item['type'], $item['id'])] = $index++;
        }

        return [$ids, $positions];
    }
855354
private function processSortBy($objects)
    {
        if (count($objects) > 0) {
            foreach ($objects as $key => $row) {
                if (array_key_exists($this->sortByField, $row)) {
                    $sort[$key] = $row[$this->sortByField];
                }
            }

            array_multisort($sort, $this->sortByDirection, $objects);
        }

        return $objects;
    }
721691
public function arSort($sort = null)
    {
        if ($sort !== null && ! is_int($sort)) {
            throw new \InvalidArgumentException(
                'Invalid sort type. Sort type must ne integer.',
                E_USER_ERROR
            );
        }

        return $sort === null
            ? arsort($this->storedData)
            : arsort($this->storedData, $sort);
    }
1365488
public function useSortings(Sortings $sortings)
    {
        foreach($sortings->getSortings() as $sorting) {
            $this->useSorting($sorting);
        }

        return $this;
    }
495897
public function buildSortFields($fields)
    {
        $sortFields = [];
        foreach ((array)$fields as $key => $value) {
            if (is_int($key)) {
                $sortFields[$value] = +1;
            } else {
                if ($value === SORT_ASC) {
                    $value = +1;
                } elseif ($value === SORT_DESC) {
                    $value = -1;
                }
                $sortFields[$key] = $value;
            }
        }
        return $sortFields;
    }
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;
	}
894394
public static function sortRecursive($array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                $value = static::sortRecursive($value);
            }
        }

        if (static::isAssociative($array)) {
            ksort($array);
        } else {
            sort($array);
        }

        return $array;
    }
402243
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->fixPaths($item);
        }

        return $items;
    }
278104
public static function order($items) {
		if (empty($items)) {
			return array();
		}

		$_items = array_combine(array_keys($items), Hash::extract($items, '{s}.weight'));
		asort($_items);

		foreach (array_keys($_items) as $key) {
			$_items[$key] = $items[$key];
		}

		return $items;
	}
92952
protected function _load(array $filter, array $sort)
    {
        $result = array();
        foreach ($this->getItemsOrdered() as $item) {
            $result[0][$item] = $item;
        }
        return $result;
    }
1262226
protected static function convertSort($sort)
  {
    /** @var RSort $convertedSort */
    $convertedSort = null;
    if (!empty($sort)) {
      $convertedSort = new RSort();
      $convertedSort->setField($sort->getField());
      switch ($sort->getOrder()) {
        case MSort\Order::Ascending:
          $convertedSort->setOrder(RSort\Order::Ascending);
          break;
        case MSort\Order::Descending:
          $convertedSort->setOrder(RSort\Order::Descending);
          break;
      }
    }
    return $convertedSort;
  }
411668
private function sort(array $databases, $sort, $reverseSort)
    {
        switch ($sort) {
            case 'name':
                ksort($databases);
                break;

            case 'size':
                uasort(
                    $databases,
                    function ($a, $b) {
                        return $a['size'] > $b['size'];
                    }
                );
                break;

            default:
                throw new Exception\DomainException("Invalid sort option \"$sort\".");
        }

        if ($reverseSort) {
            $databases = array_reverse($databases, true);
        }

        return $databases;
    }
709468
protected function toArray( array $items )
	{
		$data = [];

		foreach( $items as $item )
		{
			foreach( $item->toArray( true ) as $key => $value ) {
				$data[$key][] = $value;
			}
		}

		return $data;
	}
1321700
public static function sortByArray(array $sortArray, array $mapArray): array
    {
        $sortedArray = [];
        foreach ((array) $mapArray as $id) {
            if (array_key_exists($id, $sortArray)) {
                $sortedArray[] = $sortArray[$id];
            }
        }

        return $sortedArray;
    }