You are here

function _menu_sort in Drupal 4

Same name and namespace in other branches
  1. 5 includes/menu.inc \_menu_sort()

Comparator routine for use in sorting menu items.

5 string references to '_menu_sort'
menu_overview_tree_rows in modules/menu.module
menu_parent_options in modules/menu.module
Return a list of menu items that are valid possible parents for the given menu item. The list excludes the given item and its children.
_menu_append_contextual_items in includes/menu.inc
Account for menu items that are only defined at certain paths, so will not be cached.
_menu_build_local_tasks in includes/menu.inc
Find all the items in the current local task tree.
_menu_build_visible_tree in includes/menu.inc
Find all visible items in the menu tree, for ease in displaying to user.

File

includes/menu.inc, line 995
API for the Drupal menu system.

Code

function _menu_sort($a, $b) {
  $menu = menu_get_menu();
  $a =& $menu['items'][$a];
  $b =& $menu['items'][$b];
  if ($a['weight'] < $b['weight']) {
    return -1;
  }
  elseif ($a['weight'] > $b['weight']) {
    return 1;
  }
  elseif (isset($a['title']) && isset($b['title'])) {
    return strnatcasecmp($a['title'], $b['title']);
  }
  else {
    return 1;
  }
}