function ConfigConfigurator::recursiveSortByKey
Same name in other branches
- 11.x core/lib/Drupal/Core/Recipe/ConfigConfigurator.php \Drupal\Core\Recipe\ConfigConfigurator::recursiveSortByKey()
Sorts an array recursively, by key, alphabetically.
@todo Remove when https://www.drupal.org/project/drupal/issues/3230826 is fixed in core.
Parameters
mixed[] $data: The array to sort, passed by reference.
1 call to ConfigConfigurator::recursiveSortByKey()
- ConfigConfigurator::__construct in core/
lib/ Drupal/ Core/ Recipe/ ConfigConfigurator.php
File
-
core/
lib/ Drupal/ Core/ Recipe/ ConfigConfigurator.php, line 62
Class
- ConfigConfigurator
- @internal This API is experimental.
Namespace
Drupal\Core\RecipeCode
private static function recursiveSortByKey(array &$data) : void {
// If the array is a list, it is by definition already sorted.
if (!array_is_list($data)) {
ksort($data);
}
foreach ($data as &$value) {
if (is_array($value)) {
self::recursiveSortByKey($value);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.