function _rules_ui_sort_categories

Helper for sorting categories.

1 string reference to '_rules_ui_sort_categories'
RulesUICategory::getOptions in ui/ui.core.inc
Returns an array of options to use with a select.

File

ui/ui.core.inc, line 1359

Code

function _rules_ui_sort_categories($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['label']) ? $a['label'] : '';
    $b_title = isset($b['label']) ? $b['label'] : '';
    return strnatcasecmp($a_title, $b_title);
  }
  return $a_weight < $b_weight ? -1 : 1;
}