You are here

function _form_sort in Drupal 4

Function used by uasort in form_render() to sort form by weight.

Related topics

1 string reference to '_form_sort'
form_render in includes/form.inc
Renders a HTML form given a form tree. Recursively iterates over each of the form elements, generating HTML code. This function is usually called from within a theme. To render a form from within a module, use drupal_get_form().

File

includes/form.inc, line 582

Code

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