You are here

protected function TreeRebuilder::sortItems in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 src/Storage/TreeRebuilder.php \Drupal\entity_hierarchy\Storage\TreeRebuilder::sortItems()

Sort callback.

Parameters

array $a: Item.

array $b: Item.

Return value

int Sort order.

File

src/Storage/TreeRebuilder.php, line 101

Class

TreeRebuilder
Defines a class for rebuilding the tree.

Namespace

Drupal\entity_hierarchy\Storage

Code

protected function sortItems(array $a, array $b) {
  $a_path = (string) $a['materialized_path'];
  $b_path = (string) $b['materialized_path'];
  if ($a_path === $b_path) {
    return 0;
  }
  return $a_path < $b_path ? -1 : 1;
}