You are here

function _element_sort in Drupal 5

Function used by uasort in drupal_render() to sort structured arrays by weight.

Related topics

1 string reference to '_element_sort'
drupal_render in includes/common.inc
Renders HTML given a structured array tree. Recursively iterates over each of the array elements, generating HTML code. This function is usually called from within a another function, like drupal_get_form() or node_view().

File

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

Code

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