function ctools_menu_sort in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/menu.inc \ctools_menu_sort()
Re-sort menu items after we have modified them.
1 string reference to 'ctools_menu_sort'
- _ctools_menu_add_dynamic_items in includes/
menu.inc
File
- includes/
menu.inc, line 410 - General menu helper functions.
Code
function ctools_menu_sort($a, $b) {
$a_weight = is_array($a) && isset($a['weight']) ? $a['weight'] : 0;
$b_weight = is_array($b) && isset($b['weight']) ? $b['weight'] : 0;
if ($a_weight == $b_weight) {
$a_title = is_array($a) && isset($a['title']) ? $a['title'] : 0;
$b_title = is_array($b) && isset($b['title']) ? $b['title'] : 0;
if ($a_title == $b_title) {
return 0;
}
return $a_title < $b_title ? -1 : 1;
}
return $a_weight < $b_weight ? -1 : 1;
}