public static function ConfigEntityBase::sort

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

2 calls to ConfigEntityBase::sort()
Action::sort in drupal/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php
Helper callback for uasort() to sort configuration entities by weight and label.
ConfigTest::sort in drupal/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
2 methods override ConfigEntityBase::sort()
Action::sort in drupal/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php
Helper callback for uasort() to sort configuration entities by weight and label.
ConfigTest::sort in drupal/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().

File

drupal/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php, line 138
Definition of Drupal\Core\Config\Entity\ConfigEntityBase.

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

public static function sort($a, $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;
}