You are here

function advanced_help_uasort in Advanced Help 6

Same name and namespace in other branches
  1. 5 advanced_help.module \advanced_help_uasort()
  2. 7 advanced_help.module \advanced_help_uasort()

Helper function to sort topics.

2 string references to 'advanced_help_uasort'
advanced_help_get_tree in ./advanced_help.module
Build a tree of advanced help topics.
advanced_help_view_topic in ./advanced_help.module
Load and render a help topic.

File

./advanced_help.module, line 104
Pluggable system to provide advanced help facilities for Drupal and modules.

Code

function advanced_help_uasort($id_a, $id_b) {
  $topics = advanced_help_get_topics();
  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;
}