element_sort

  1. drupal
    1. 6
    2. 8
    3. 7
Versions
6 – 8 element_sort($a, $b)

Function used by uasort to sort structured arrays by weight.

Code

includes/common.inc, line 6023

<?php
function element_sort($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;
}
?>