### Eclipse Workspace Patch 1.0
#P 19stable
Index: group/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/group/lib.php,v
retrieving revision 1.8.2.9
diff -u -r1.8.2.9 lib.php
--- group/lib.php	6 Jul 2008 22:54:05 -0000	1.8.2.9
+++ group/lib.php	17 Oct 2009 03:01:23 -0000
@@ -395,11 +395,20 @@
  * @return array An array of role id or '*' => information about that role 
  *   including a list of users
  */
-function groups_get_users_not_in_group_by_role($courseid, $groupid, $searchtext='', $sort = 'u.lastname ASC') {
-
+function groups_get_users_not_in_group_by_role($courseid, $groupid, $searchtext='', $sort = 'u.lastname ASC, u.firstname ASC') {
     global $CFG;
     $context = get_context_instance(CONTEXT_COURSE, $courseid);
     
+    if (isset($CFG->fullnamedisplay)) {
+        $sort = ($CFG->fullnamedisplay == 'lastname firstname') ? 'u.lastname ASC, u.firstname ASC' : 'u.firstname ASC, u.lastname ASC';
+        if ($CFG->fullnamedisplay == 'language') {
+            $fullnamelanguage = get_string('fullnamedisplay');
+            if ($fullnamelanguage == 'lastname firstname' ) { 
+                $sort = 'u.lastname ASC, u.firstname ASC';
+            }
+        }
+    }
+    
     if ($searchtext !== '') {   // Search for a subset of remaining users
         $LIKE      = sql_ilike();
         $FULLNAME  = sql_fullname();
