summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc12
1 files changed, 10 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc
index c1dc6f8f2..7b97fe67d 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3493,11 +3493,19 @@ function element_children(&$elements, $sort = FALSE) {
}
}
}
- // Sort the element if necessary.
+ // Sort the children if necessary.
if ($sort && $sortable) {
uasort($children, 'element_sort');
+ // Put the sorted children back into $elements in the correct order, to
+ // preserve sorting if the same element is passed through
+ // element_children() twice.
+ foreach ($children as $key => $child) {
+ unset($elements[$key]);
+ $elements[$key] = $child;
+ }
+ $elements['#sorted'] = TRUE;
}
- $elements['#sorted'] = TRUE;
+
return array_keys($children);
}