function element_sort in Drupal 6
Same name and namespace in other branches
- 7 includes/common.inc \element_sort()
Function used by uasort to sort structured arrays by weight.
3 string references to 'element_sort'
- drupal_render in includes/
common.inc - Renders HTML given a structured array tree.
- template_preprocess_user_profile in modules/
user/ user.pages.inc - Process variables for user-profile.tpl.php.
- upload_node_form_submit in modules/
upload/ upload.module - Save new uploads and store them in the session to be associated to the node on upload_save.
File
- includes/
common.inc, line 3093 - 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;
}