Sorts the given resolvers.

@param array $resolvers An array of resolvers.

@return array An array of resolvers sorted by priority.
770956
protected function sortResolvers(array $resolvers)
    {
        usort($resolvers, function ($a, $b) {
            if ($a['priority'] == $b['priority']) {
                return 0;
            }

            return ($a['priority'] > $b['priority']) ? -1 : 1;
        });

        $sortedResolvers = [];
        foreach ($resolvers as $resolver) {
            $sortedResolvers[] = $resolver['resolver'];
        }

        return $sortedResolvers;
    }
358347
public function resolve(array $headers)
    {
        if (!isset($headers[HeaderTypeEnum::CONTENT_TYPE]) ||
            !isset($this->messageSerializers[$headers[HeaderTypeEnum::CONTENT_TYPE]])
        ) {
            return $this->defaultSerializer;
        }

        return $this->messageSerializers[$headers[HeaderTypeEnum::CONTENT_TYPE]];
    }
308680
private function sortCalendars($calendars)
    {
        $calendarsSorted = array();
        foreach ($calendars as $calendar) {
            $calendarsSorted[$calendar->id] = $calendar;
            $calendarsSorted[$calendar->id]->week_pattern = (array) $calendarsSorted[$calendar->id]->week_pattern;
        }

        return $calendarsSorted;
    }
105595
public function addFormFieldResolver(FormFieldResolverInterface $resolver, $priority = 0)
    {
        $this->formFieldResolvers[$priority][] = $resolver;
        $this->needsSorting = true;
    }
1079078
protected function getResolvedOptions(array $options)
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults(array(
                'processClass' => 'Symfony\\Component\\Process\\Process',
            ))
            ->setRequired(array('folder'))
            ->setAllowedTypes(array(
                'processClass' => 'string',
                'folder' => 'string',
            ))
        ;

        return $resolver->resolve($options);
    }
1114461
protected function sort($assets)
    {
        $original = $assets;
        $sorted = [];

        while (count($assets) > 0) {
            foreach ($assets as $handle => $asset) {
                // No dependencies anymore, add it to sorted
                if (!$asset->hasDependency()) {
                    $sorted[$handle] = $asset;
                    unset($assets[$handle]);
                } else {
                    foreach ($asset->getDependency() as $dep) {
                        // Remove dependency if doesn't exist, if its dependent on itself,
                        // or if the dependent is dependent on it
                        if (!isset($original[$dep]) or $dep === $handle or (isset($assets[$dep]) and $assets[$dep]->hasDependency($handle))) {
                            $assets[$handle]->removeDependency($dep);
                            continue;
                        }

                        // This dependency hasn't been sorted yet
                        if (!isset($sorted[$dep])) {
                            continue;
                        }

                        // This dependency is taken care of, remove from list
                        $assets[$handle]->removeDependency($dep);
                    }
                }
            }
        }

        return $sorted;
    }
354272
public function sort(array $fixtures)
    {
        $this->fixtures        = $fixtures;
        $this->orderedFixtures = [];

        $usePrioritySorting     = $this->usePrioritySorting($fixtures);
        $useDependenciesSorting = $this->useDependenciesSorting($fixtures);


        if ($usePrioritySorting) {
            $this->orderFixturesByNumber();
        }

        if ($useDependenciesSorting) {
            $this->orderFixturesByDependencies($usePrioritySorting);
        }

        if (!($usePrioritySorting || $useDependenciesSorting)) {
            $this->orderedFixtures = $fixtures;
        }

        return $this->orderedFixtures;
    }
1033067
public function resolve(array $options)
    {
        $reflectedClassName = $this->reflected->getName();

        // We check if that constructor has been configured before and is in the registry
        if (!isset(self::$resolvers[$reflectedClassName])) {
            self::$resolvers[$reflectedClassName] = new OptionsResolver();

            $this->configureOptions(self::$resolvers[$reflectedClassName]);
        }

        return $this->hashToArgsArray(
            self::$resolvers[$reflectedClassName]->resolve($options)
        );
    }
293421
public function prepareSort(array $fields) : array
    {
        $sortFields = [];

        foreach ($fields as $key => $value) {
            if (is_array($value)) {
                $sortFields[$this->prepareFieldName($key)] = $value;
            } else {
                $sortFields[$this->prepareFieldName($key)] = $this->getSortDirection($value);
            }
        }

        return $sortFields;
    }
231441
private function configure(array $options = []): array
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            'max_restarts' => 10,
        ]);

        $resolver->setAllowedTypes('max_restarts', 'int');

        return $resolver->resolve($options);
    }
100907
private function resolveArgs(array $args)
    {
        $resolved = [];
        foreach ($args as $argDefinition) {
            switch ($argDefinition['type']) {
                case 'lookup':
                    $resolved[] = $this->lookupRecursive($argDefinition['item']);
                    break;
                case 'value':
                    $resolved[] = $argDefinition['item'];
                    break;
            }
        }

        return $resolved;
    }
577304
public function prependResolver(EntryNameResolverInterface $resolver)
    {
        $priority = self::DEFAULT_PRIORITY;

        if (!$this->resolvers->isEmpty()) {
            $queue = $this->resolvers->getIterator();
            $queue->setExtractFlags(PriorityQueue::EXTR_PRIORITY);
            $extractedNode = $queue->extract();
            $priority = $extractedNode[0] + 1;
        }

        $this->resolvers->insert(
            [
                'instance' => $resolver,

            ],
            $priority
        );

        return $this;
    }
845696
protected function orderByPart(array $aliases) {
        $sortFields = [];

        foreach ($aliases as $alias) {
            $sortFields[] = $this->getDriverEscaper()->reserved($alias['name']) . '.' .
                    $this->getDriverEscaper()->reserved('object') . ' ' .
                    $alias['dir'] . $this->operationSeparator;
        }

        $result = $this->getDriverEscaper()->dbCommand('ORDER BY') . ' ' .
                implode($this->getDriverEscaper()->getFieldsSeparator(), $sortFields)
                . $this->operationSeparator;

        return $result;
    }
909760
public static function sortArray(array $versions)
    {
        // Empty array does not needs sorting
        if (count($versions) === 0) {
            return array();
        }

        // Array of one item (pivot) from the middle
        $pivotArray = array_splice(
            $versions,
            (int) floor((count($versions) - 1) / 2),
            1
        );

        // Smaller/greater than pivot stack
        $smaller = array();
        $greater = array();

        // Fill stacks
        foreach($versions as $version) {
            if (Compare::greaterThan($version, $pivotArray[0])) {
                $greater[] = $version;
            } else {
                $smaller[] = $version;
            }
        }

        // Recurse and merge results
        return array_merge(
            self::sortArray($smaller),
            $pivotArray,
            self::sortArray($greater)
        );
    }
425637
private function resolveHashes(array $hashes)
    {
        $assoc = [];
        foreach ($hashes as $k => $hash) {
            $item = $this->resolveHash($hash);
            if ($item) {
                $assoc[$k] = $item;
            }
        }

        return $assoc;
    }
1041436
protected void sortResolvedResources(List<HalResource<?>> resolvedResources) {
    Comparator<HalResource<?>> comparator = getResourceComparator();
    if (comparator != null) {
      Collections.sort(resolvedResources, comparator);
    }
  }
1041234
protected function resolveOptions(array $options = [], callable $optionsConfigurator): array
    {
        $resolver = new OptionsResolver();
        call_user_func_array($optionsConfigurator, [$resolver]);

        return $resolver->resolve($options);
    }