You are here

private function AdvancedHelpController::helpUasort in Advanced Help 8

Helper function to sort topics.

Parameters

string $id_a:

string $id_b:

Return value

mixed

File

src/Controller/AdvancedHelpController.php, line 139

Class

AdvancedHelpController
Class AdvancedHelpController.

Namespace

Drupal\advanced_help\Controller

Code

private function helpUasort($id_a, $id_b) {
  $topics = $this->advanced_help
    ->getTopics();
  list($module_a, $topic_a) = $id_a;
  $a = $topics[$module_a][$topic_a];
  list($module_b, $topic_b) = $id_b;
  $b = $topics[$module_b][$topic_b];
  $a_weight = isset($a['weight']) ? $a['weight'] : 0;
  $b_weight = isset($b['weight']) ? $b['weight'] : 0;
  if ($a_weight != $b_weight) {
    return $a_weight < $b_weight ? -1 : 1;
  }
  if ($a['title'] != $b['title']) {
    return $a['title'] < $b['title'] ? -1 : 1;
  }
  return 0;
}