You are here

function admin_menu_element_sort in Administration menu 7.3

Same name and namespace in other branches
  1. 8.3 admin_menu.module \admin_menu_element_sort()
  2. 6.3 admin_menu.module \admin_menu_element_sort()

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 ./admin_menu.module
Render a themed list of links.

File

./admin_menu.module, line 840
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;
}