Determines the children sorting

@param HasMany $children
512681
public function determineChildrenSorting(HasMany $children)
    {
        if (in_array($this->children_order, $this->translatedAttributes))
        {
            $children->sortedBySourceAttribute(
                $this->children_order,
                $this->children_order_direction
            );
        } else
        {
            $children->orderBy(
                $this->children_order, $this->children_order_direction
            );
        };
    }
1233405
public function getAllChildren(&$children = [])
    {
        if (!$this->allChildren && $this->getChildren()) {
            $page = $this;
            foreach ($page->getChildren() as $child) {
                $children[] = $child;
                if ($child->getChildren()) {
                    $child->getAllChildren($children);
                }
            }

            $this->setAllChildren(array_reverse($children));
        }

        return $this->allChildren;
    }
121575
public function sortTree(array $entities)
    {
        if (empty($entities)) {
            return $entities;
        }

        $class = ClassUtils::getClass(reset($entities));

        $config = $this->treeListener->getConfiguration($this->em, $class);

        if (empty($config)) {
            throw new ClassIsNotTreeException($class);
        }

        $children = [];

        foreach ($entities as $entity) {
            $parent = $this->propertyAccessor->getValue($entity, $config['parent']);

            if (empty($parent)) {
                continue;
            }

            $parentPath = $this->propertyAccessor->getValue($parent, $config['path_source']);

            if (!isset($children[$parentPath])) {
                $children[$parentPath] = [];
            }

            $children[$parentPath][$this->propertyAccessor->getValue($entity, $config['path_source'])] = $entity;
        }

        $sorted = [];

        foreach ($entities as $entity) {
            $this->addEntity($sorted, $entity, $children, $config);
        }

        return array_values($sorted);
    }
1374287
public function containsChildrenEntities(array $childrenEntities)
    {
        foreach ($childrenEntities as $childrenEntity) {
            if (!$this->childrenEntities->contains($childrenEntity)) {
                return false;
            }
        }

        return true;
    }
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)
        );
    }
653009
public function sortCategories(array $items)
    {
        $repository = $this->getRepository();
        $em         = $this->getDoctrineHelper()->getEntityManager();

        foreach ($items as $item) {
            $parent = $repository->find($item['parent']);
            $child  = $repository->find($item['id']);
            if (null !== $child) {
                $child->setParent($parent);
                $child->setHierarchy($item['weight']);
                $em->persist($child);
            }
        }

        $em->flush();
    }
1144272
private boolean hasSelectedChildren(List<CmsCategoryTreeEntry> children, Collection<String> selectedCategories) {

        boolean result = false;
        if (children == null) {
            return false;
        }
        for (CmsCategoryTreeEntry child : children) {
            result = selectedCategories.contains(child.getSitePath());
            if (result || hasSelectedChildren(child.getChildren(), selectedCategories)) {
                return true;
            }
        }

        return result;
    }
1113552
public function setChildren(array $children): NodeInterface
    {
        foreach ($this->getChildren() as $node) {
            $this->removeChild($node->getId());
        }

        foreach ($children as $child) {
            $this->addChild($child);
        }

        return $this;
    }
235888
function sortChildren(parent, sortingFunction) {
  if (!parent.children) return;
  parent.children = new Map([...parent.children.entries()].sort(sortingFunction));
  for (var i = 0; i < parent.children.length; ++i)
    recalculateSiblings(parent.children[i], i);
  for (var child of parent.children.values())
    sortChildren(child, sortingFunction);
}
149063
public function hasMany($hasMany = null)
    {
        if ($hasMany === null)
        {
            return $this->_hasMany;
        }
        $this->_hasMany = $hasMany;

        return $this;
    }
576827
public function sort(array &$methods, $sort = self::BY_COMPLEXITY)
    {
        if (!in_array($sort, self::SORTS, true)) {
            $sort = self::BY_COMPLEXITY;
        }

        usort(
            $methods,
            $sort === self::BY_COMPLEXITY
                ? $this->byComplexity()
                : $this->byName()
        );
    }
881584
public function buildNewCollection(array $children) : \Dms\Core\Model\ITypedCollection
    {
        return $this->mapper->buildCollection($children);
    }
529217
public function setChildren($children)
    {
        $children = (array) $children;

        foreach ($children as $argument) {
            $this->addCommand($argument);
        }

        return $this;
    }
45780
public function removeChildren(\Coral\ContentBundle\Entity\Node $children)
    {
        $this->children->removeElement($children);
    }
1304351
protected function sortCollection($objects)
    {
        $class = false;

        if ($objects instanceof Arrayable) {
            $class = get_class($objects);

            $objects = $objects->toArray();
        }

        usort($objects, function ($aObj, $bObj) {
            list($aRank, $bRank) = $this->getRanks($aObj, $bObj);

            if ($this->equals($aRank, $bRank)) {
                return $this->sortByName($aObj, $bObj);
            }

            return $this->sortByValue($aRank, $bRank);
        });

        return $class ? $class::make($objects) : $objects;
    }
230933
public function removeChildren(Collection $children)
    {
        foreach ($children as $child) {
                $this->removeChild($child);
        }

        return $this;
    }
1003086
private function sortServices($services)
    {
        uasort($services, static function ($a, $b) {
            if ($a->getName() === $b->getName()) {
                return 0;
            }

            return ($a->getName() < $b->getName()) ? -1 : 1;
        });

        return $services;
    }