1.20.x drupal.inc element_sort($a, $b)

Sorts a structured array by '#weight' property.

Deprecated

since 1.0.0

See also

backdrop_sort()

Related topics

File

includes/drupal.inc, line 1334
Contains constants and function wrappers for Drupal 7.x compatibility.

Code

function element_sort($a, $b) {
  watchdog_deprecated_function('drupal', __FUNCTION__);
  $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;
}