function _menu_sort in Drupal 5
Same name and namespace in other branches
- 4 includes/menu.inc \_menu_sort()
Comparator routine for use in sorting menu items.
7 string references to '_menu_sort'
- menu_overview_tree_rows in modules/
menu/ menu.module - menu_parent_options in modules/
menu/ 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.
- system_admin_menu_block in modules/
system/ system.module - Provide a single block on the administration overview page.
- system_main_admin_page in modules/
system/ system.module - Provide the administration overview page.
- _menu_append_contextual_items in includes/
menu.inc - Account for menu items that are only defined at certain paths, so will not be cached.
File
- includes/
menu.inc, line 1012 - 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;
}
}