From d76786c183706942053d27e454e441b290400ee7 Mon Sep 17 00:00:00 2001
From: Niklas Fiekas <niklas.fiekas@googlemail.com>
Date: Sun, 7 Aug 2011 21:03:55 +0200
Subject: [PATCH] Issue 1241662 by Niklas Fiekas: Sort modules by display name

The default module page uses uasort with the callback
system_sort_modules_by_info_name to sort the modules by display name.

 - Add a sorting callback: module_filter_sort_modules_by_display_name
 - Use uasort to sort the module list

Reported by LarsKramer.
---
 module_filter.module |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/module_filter.module b/module_filter.module
index f8894ae..8db460b 100644
--- a/module_filter.module
+++ b/module_filter.module
@@ -97,7 +97,7 @@ function module_filter_form_system_modules_alter(&$form, $form_state) {
     }
 
     // Sort the array of modules alphabetically.
-    ksort($modules);
+    uasort($modules, 'module_filter_sort_modules_by_display_name');
 
     // Replace the $form['modules'] with our $modules array.
     $form['modules'] = $modules;
@@ -107,6 +107,15 @@ function module_filter_form_system_modules_alter(&$form, $form_state) {
 }
 
 /**
+ * Array sorting callback; sorts modules by their display name.
+ */
+function module_filter_sort_modules_by_display_name($a, $b) {
+  if (is_array($a) && is_array($b) && isset($a['#package'], $b['#package'])) {
+    return strcasecmp($a['name']['#markup'], $b['name']['#markup']);
+  }
+}
+
+/**
  * Implementation of hook_theme().
  */
 function module_filter_theme() {
-- 
1.7.4.4

