You are here

public function renderCheeseburgerMenuBlock::bubbleSortWeight in Cheeseburger Menu 8

Same name and namespace in other branches
  1. 8.2 src/Controller/RenderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\RenderCheeseburgerMenuBlock::bubbleSortWeight()
  2. 8.3 src/Controller/RenderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\RenderCheeseburgerMenuBlock::bubbleSortWeight()
1 call to renderCheeseburgerMenuBlock::bubbleSortWeight()
renderCheeseburgerMenuBlock::render_tree in src/Controller/renderCheeseburgerMenuBlock.php

File

src/Controller/renderCheeseburgerMenuBlock.php, line 526

Class

renderCheeseburgerMenuBlock

Namespace

Drupal\cheeseburger_menu\Controller

Code

public function bubbleSortWeight($sort) {
  do {
    $change = FALSE;
    for ($i = 0; $i < count($sort) - 1; $i++) {
      if ($sort[$i]['weight'] > $sort[$i + 1]['weight']) {
        $temp = $sort[$i];
        $sort[$i] = $sort[$i + 1];
        $sort[$i + 1] = $temp;
        $change = TRUE;
      }
    }
  } while ($change == TRUE);
  return $sort;
}