function drupal_sort_weight

cis7 common.inc drupal_sort_weight($a, $b)
cle7 common.inc drupal_sort_weight($a, $b)
elmsmedia7 common.inc drupal_sort_weight($a, $b)
icor7 common.inc drupal_sort_weight($a, $b)
meedjum_blog7 common.inc drupal_sort_weight($a, $b)
mooc7 common.inc drupal_sort_weight($a, $b)

Sorts a structured array by the 'weight' element.

Note that the sorting is by the 'weight' array element, not by the render element property '#weight'.

Callback for uasort() used in various functions.

Parameters

$a: First item for comparison. The compared items should be associative arrays that optionally include a 'weight' element. For items without a 'weight' element, a default value of 0 will be used.

$b: Second item for comparison.

16 string references to 'drupal_sort_weight'
alpha_theme_container::regions in sites/all/themes/ulmus/omega/alpha/includes/base.inc
@todo
alpha_theme_container::zones in sites/all/themes/ulmus/omega/alpha/includes/base.inc
@todo
archiver_get_info in includes/common.inc
Retrieves a list of all available archivers.
drupal_get_filetransfer_info in includes/common.inc
Assembles the Drupal FileTransfer registry.
drupal_get_updaters in includes/common.inc
Assembles the Drupal Updater registry.

... See full list

File

includes/common.inc, line 6356
Common functions that many Drupal modules will need to reference.

Code

function drupal_sort_weight($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) {
    return 0;
  }
  return ($a_weight < $b_weight) ? -1 : 1;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.