You are here

function _admin_menu_sort in Administration menu 5.2

Same name and namespace in other branches
  1. 5.3 admin_menu.module \_admin_menu_sort()

Comparator routine for use in sorting menu items.

1 string reference to '_admin_menu_sort'
theme_admin_menu_tree in ./admin_menu.module
Generate the HTML for a menu tree.

File

./admin_menu.module, line 299
Renders a menu tree for administrative purposes as dropdown menu at the top of the window.

Code

function _admin_menu_sort($a, $b) {
  $_admin_menu = admin_menu_get_menu();
  $a = $_admin_menu[$a];
  $b = $_admin_menu[$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;
  }
}