Skip navigation
Help

drupal_sort_weight

7 common.inc drupal_sort_weight($a, $b)

Function used by uasort to sort structured arrays by weight, without the property weight prefix.

8 string references to 'drupal_sort_weight'

File

drupal/includes/common.inc, line 6073
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;
}