You are here

function ctools_plugin_sort in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/plugins.inc \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
Contains routines to organize and load plugins. It allows a special variation of the hook system so that plugins can be kept in separate .inc files, and can be either loaded all at once or loaded only when necessary.

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;
}