function admin_menu_element_sort

nittany7 admin_menu.module admin_menu_element_sort($a, $b)
cis7 admin_menu.module admin_menu_element_sort($a, $b)
mooc7 admin_menu.module admin_menu_element_sort($a, $b)

Function used by uasort to sort structured arrays by #weight AND #title.

1 string reference to 'admin_menu_element_sort'
theme_admin_menu_links in modules/contrib/admin_menu/admin_menu.module
Render a themed list of links.

File

modules/contrib/admin_menu/admin_menu.module, line 720
Render an administrative menu as a dropdown menu at the top of the window.

Code

function admin_menu_element_sort($a, $b) {
  // @see element_sort()
  $a_weight = isset($a['#weight']) ? $a['#weight'] : 0;
  $b_weight = isset($b['#weight']) ? $b['#weight'] : 0;
  if ($a_weight == $b_weight) {
    // @see element_sort_by_title()
    $a_title = isset($a['#title']) ? $a['#title'] : '';
    $b_title = isset($b['#title']) ? $b['#title'] : '';
    return strnatcasecmp($a_title, $b_title);
  }
  return ($a_weight < $b_weight) ? -1 : 1;
}