public static function WeMegaMenuBuilder::sortMenu in Drupal Mega Menu 8
Same name and namespace in other branches
- 8.x src/WeMegaMenuBuilder.php \Drupal\we_megamenu\WeMegaMenuBuilder::sortMenu()
Sort menu by weight.
Parameters
string $menu: Public static function sortMenu string menu.
Return value
array Public static function sortMenu array.
2 calls to WeMegaMenuBuilder::sortMenu()
- WeMegaMenuBuilder::orderMenuItems in src/
WeMegaMenuBuilder.php - Order display menu item.
- WeMegaMenuBuilder::sortMenuDeep in src/
WeMegaMenuBuilder.php - Sort list child menu.
File
- src/
WeMegaMenuBuilder.php, line 132
Class
Namespace
Drupal\we_megamenuCode
public static function sortMenu($menu) {
for ($i = 0; $i < count($menu); $i++) {
for ($j = $i + 1; $j < count($menu); $j++) {
if ($menu[$i]['weight'] > $menu[$j]['weight']) {
$menu_tmp = $menu[$i];
$menu[$i] = $menu[$j];
$menu[$j] = $menu_tmp;
}
}
}
return $menu;
}