function element_sort
7.x common.inc | element_sort($a, $b) |
6.x common.inc | element_sort($a, $b) |
Function used by uasort to sort structured arrays by weight.
2 string references to 'element_sort'
- template_preprocess_user_profile in drupal-6.x/
modules/ user/ user.pages.inc - Process variables for user-profile.tpl.php.
- upload_node_form_submit in drupal-6.x/
modules/ upload/ upload.module - Save new uploads and store them in the session to be associated to the node on upload_save.
File
- drupal-6.x/
includes/ common.inc, line 3067 - 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;
}