public function FilterBag::sortHelper

uasort() callback to sort filters by status, weight, module, and name.

See also

\Drupal\filter\FilterFormatStorageController::preSave()

File

drupal/core/modules/filter/lib/Drupal/filter/FilterBag.php, line 152
Contains \Drupal\filter\FilterBag.

Class

FilterBag
A collection of filters.

Namespace

Drupal\filter

Code

public function sortHelper($aID, $bID) {
  $a = $this
    ->get($aID);
  $b = $this
    ->get($bID);
  if ($a->status != $b->status) {
    return !empty($a->status) ? -1 : 1;
  }
  if ($a->weight != $b->weight) {
    return $a->weight < $b->weight ? -1 : 1;
  }
  if ($a->module != $b->module) {
    return strnatcasecmp($a->module, $b->module);
  }
  return strnatcasecmp($a
    ->getPluginId(), $b
    ->getPluginId());
}