You are here

public function TBMegaMenuBuilder::sortByWeight in The Better Mega Menu 2.x

Same name and namespace in other branches
  1. 8 src/TBMegaMenuBuilder.php \Drupal\tb_megamenu\TBMegaMenuBuilder::sortByWeight()

Sort menu items by weight.

Parameters

array $item_sorted: The unsorted weights of all menu items.

Return value

array All weights sorted lowest to highest.

Overrides TBMegaMenuBuilderInterface::sortByWeight

1 call to TBMegaMenuBuilder::sortByWeight()
TBMegaMenuBuilder::syncOrderMenus in src/TBMegaMenuBuilder.php
Sync order of menu items between menu and tb_megamenus.

File

src/TBMegaMenuBuilder.php, line 488

Class

TBMegaMenuBuilder
Defines a TBMegaMenuBuilder.

Namespace

Drupal\tb_megamenu

Code

public function sortByWeight(array $item_sorted) {
  ksort($item_sorted);
  $new_list = [];
  foreach ($item_sorted as $weight_group) {
    foreach ($weight_group as $item) {
      $new_list[] = $item;
    }
  }
  return $new_list;
}