Index: bp-core/bp-core-classes.php
===================================================================
--- bp-core/bp-core-classes.php	(revision 7302)
+++ bp-core/bp-core-classes.php	(working copy)
@@ -281,15 +281,21 @@
 			// 'alphabetical' sorts depend on the xprofile setup
 			case 'alphabetical' :
 
+				// Even if it penalizes performance, the use of last_activity is interesting to
+				// - neutralize the display of spammers and to avoid 404 for non admins
+				// - have a count that is coherent with the tab "All Members"
+				$this->uid_name = 'user_id';
+				$sql['select']  = "SELECT DISTINCT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u";
+				$sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );
+
 				// We prefer to do alphabetical sorts against the display_name field
 				// of wp_users, because the table is smaller and better indexed. We
 				// can do so if xprofile sync is enabled, or if xprofile is inactive.
 				//
 				// @todo remove need for bp_is_active() check
 				if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) {
-					$this->uid_name = 'ID';
-					$sql['select']  = "SELECT DISTINCT u.{$this->uid_name} as id FROM {$wpdb->users} u";
-					$sql['orderby'] = "ORDER BY u.display_name";
+					$sql['select']  .= " LEFT JOIN {$wpdb->users} us ON( u.{$this->uid_name} = us.ID )";
+					$sql['orderby'] = "ORDER BY us.display_name";
 					$sql['order']   = "ASC";
 
 				// When profile sync is disabled, alphabetical sorts must happen against
@@ -297,10 +303,9 @@
 				} else {
 					$fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) );
 
-					$this->uid_name = 'user_id';
-					$sql['select']  = "SELECT DISTINCT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u";
-					$sql['where'][] = "u.field_id = {$fullname_field_id}";
-					$sql['orderby'] = "ORDER BY u.value";
+					$sql['select']  .= " LEFT JOIN {$bp->profile->table_name_data} us ON( u.{$this->uid_name} = us.{$this->uid_name} )";
+					$sql['where'][] = "us.field_id = {$fullname_field_id}";
+					$sql['orderby'] = "ORDER BY us.value";
 					$sql['order']   = "ASC";
 				}
 
