function ContentExportTest::recursiveSortByKey

Recursively sorts an array by key.

Parameters

array $data: The array to sort.

1 call to ContentExportTest::recursiveSortByKey()
ContentExportTest::testExportContent in core/tests/Drupal/FunctionalTests/DefaultContent/ContentExportTest.php
Ensures that all imported content can be exported properly.

File

core/tests/Drupal/FunctionalTests/DefaultContent/ContentExportTest.php, line 180

Class

ContentExportTest
Tests exporting content in YAML format.

Namespace

Drupal\FunctionalTests\DefaultContent

Code

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.