8.5.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
8.0.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
8.1.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
8.2.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
8.3.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
8.4.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
8.6.x ConfigEntityBase.php ConfigEntityBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)

Helper callback for uasort() to sort configuration entities by weight and label.

4 calls to ConfigEntityBase::sort()
Action::sort in core/modules/system/src/Entity/Action.php
Helper callback for uasort() to sort configuration entities by weight and label.
ConfigTest::sort in core/modules/config/tests/config_test/src/Entity/ConfigTest.php
Helper callback for uasort() to sort configuration entities by weight and label.
EntityDisplayModeBase::sort in core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php
Helper callback for uasort() to sort configuration entities by weight and label.
SearchPage::sort in core/modules/search/src/Entity/SearchPage.php
Helper callback for uasort() to sort configuration entities by weight and label.
6 methods override ConfigEntityBase::sort()
Action::sort in core/modules/system/src/Entity/Action.php
Helper callback for uasort() to sort configuration entities by weight and label.
Block::sort in core/modules/block/src/Entity/Block.php
Sorts active blocks by weight; sorts inactive blocks by name.
ConfigTest::sort in core/modules/config/tests/config_test/src/Entity/ConfigTest.php
Helper callback for uasort() to sort configuration entities by weight and label.
DateFormat::sort in core/lib/Drupal/Core/Datetime/Entity/DateFormat.php
Helper callback for uasort() to sort configuration entities by weight and label.
EntityDisplayModeBase::sort in core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php
Helper callback for uasort() to sort configuration entities by weight and label.

... See full list

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php, line 251

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
  $a_weight = isset($a->weight) ? $a->weight : 0;
  $b_weight = isset($b->weight) ? $b->weight : 0;
  if ($a_weight == $b_weight) {
    $a_label = $a
      ->label();
    $b_label = $b
      ->label();
    return strnatcasecmp($a_label, $b_label);
  }
  return $a_weight < $b_weight ? -1 : 1;
}