function ctools_plugin_sort

Sort callback for sorting plugins naturally.

Sort first by weight, then by title.

1 string reference to 'ctools_plugin_sort'
page_manager_page_wizard_list in includes/page-wizard.inc
Provide a simple administrative list of all wizards.

File

includes/plugins.inc, line 914

Code

function ctools_plugin_sort($a, $b) {
  if (is_object($a)) {
    $a = (array) $a;
  }
  if (is_object($b)) {
    $b = (array) $b;
  }
  if (empty($a['weight'])) {
    $a['weight'] = 0;
  }
  if (empty($b['weight'])) {
    $b['weight'] = 0;
  }
  if ($a['weight'] == $b['weight']) {
    return strnatcmp(strtolower($a['title']), strtolower($b['title']));
  }
  return $a['weight'] < $b['weight'] ? -1 : 1;
}