diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 36f87ca..a54beac 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -418,7 +418,11 @@ public function getAllBundleInfo() { */ public function getEntityTypeLabels($group = FALSE) { $options = array(); - foreach ($this->getDefinitions() as $entity_type => $definition) { + $definitions = $this->getDefinitions(); + // Sort labels in alphabetical order. + ksort($definitions); + + foreach ($definitions as $entity_type => $definition) { if ($group) { $group_label = $definition->getGroupLabel() ?: \Drupal::translation()->translate('Other', array(), array('context' => 'Entity type group')); $options[$group_label][$entity_type] = $definition->getLabel(); @@ -427,8 +431,11 @@ public function getEntityTypeLabels($group = FALSE) { $options[$entity_type] = $definition->getLabel(); } } - // Sort the list alphabetically by group label. - array_multisort($options, SORT_DESC); + + if ($group) { + // Sort the list alphabetically by group label. + array_multisort($options, SORT_DESC); + } return $options; }