public function sort(array $groups)
{
if ($this->isNoneGroupOnly($groups)) {
return [];
}
$this->groups = $groups;
$groupNames = array_keys($groups);
$this->lowercasedGroupNames = $this->convertGroupNamesToLower($groupNames);
foreach ($groupNames as $groupName) {
$this->addMissingParentGroups($groupName);
$this->addMissingElementTypes($groupName);
}
uksort($this->groups, function ($one, $two) {
return $this->compareGroups($one, $two, $this->configuration->getMain());
});
return $this->groups;
}