Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.197
diff -u -9 -p -r1.197 module.inc
--- includes/module.inc	28 Jul 2010 01:46:59 -0000	1.197
+++ includes/module.inc	27 Aug 2010 17:23:39 -0000
@@ -611,19 +611,19 @@ function module_implements($hook, $sort 
     }
   }
 
   if (!isset($implementations[$hook])) {
     // The hook is not cached, so ensure that whether or not it has
     // implementations, that the cache is updated at the end of the request.
     $implementations['#write_cache'] = TRUE;
     $hook_info = module_hook_info();
     $implementations[$hook] = array();
-    $list = module_list(FALSE, FALSE, $sort);
+    $list = module_list(FALSE, FALSE);
     foreach ($list as $module) {
       $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
       if (module_hook($module, $hook)) {
         $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
       }
     }
     // Allow modules to change the weight of specific implementations but avoid
     // an infinite loop.
     if ($hook != 'module_implements_alter') {
@@ -643,19 +643,23 @@ function module_implements($hook, $sort 
       if (!module_hook($module, $hook)) {
         // Clear out the stale implementation from the cache and force a cache
         // refresh to forget about no longer existing hook implementations.
         unset($implementations[$hook][$module]);
         $implementations['#write_cache'] = TRUE;
       }
     }
   }
 
-  return array_keys($implementations[$hook]);
+  $modules = array_keys($implementations[$hook]);
+  if ($sort) {
+    sort($modules);
+  }
+  return $modules;
 }
 
 /**
  * Retrieve a list of what hooks are explicitly declared.
  */
 function module_hook_info() {
   $hook_info = &drupal_static(__FUNCTION__, array());
 
   if (empty($hook_info)) {
