#800502: restore proper ordering of the module page.

From: Damien Tournoud <damien@tournoud.net>


---
 common.inc              |    9 +++++++++
 system/system.admin.inc |    3 +++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git includes/common.inc includes/common.inc
index e8e918a..2c487f2 100644
--- includes/common.inc
+++ includes/common.inc
@@ -5299,6 +5299,15 @@ function element_sort($a, $b) {
 }
 
 /**
+ * Array sorting callback; sorts elements by title.
+ */
+function element_sort_by_title($a, $b) {
+  $a_title = (is_array($a) && isset($a['#title'])) ? $a['#title'] : '';
+  $b_title = (is_array($b) && isset($b['#title'])) ? $b['#title'] : '';
+  return strnatcasecmp($a_title, $b_title);
+}
+
+/**
  * Retrieve the default properties for the defined element type.
  */
 function element_info($type) {
diff --git modules/system/system.admin.inc modules/system/system.admin.inc
index c462fb6..53e66bb 100644
--- modules/system/system.admin.inc
+++ modules/system/system.admin.inc
@@ -942,6 +942,9 @@ function system_modules($form, $form_state = array()) {
     );
   }
 
+  // Now sort the fieldsets by title.
+  uasort($form['modules'], 'element_sort_by_title');
+
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array(
     '#type' => 'submit',
