diff -urN ../nagios-cvs.orig/cgi/status.c ./cgi/status.c
--- ../nagios-cvs.orig/cgi/status.c	Wed Mar 24 06:22:03 2004
+++ ./cgi/status.c	Wed Apr 28 15:40:39 2004
@@ -3899,7 +3899,7 @@
 				return FALSE;
 		        }
 		else if(s_option==SORT_HOSTNAME){
-			if(strcasecmp(new_svcstatus->host_name,temp_svcstatus->host_name)<0)
+			if(str_domain_compare(new_svcstatus->host_name,temp_svcstatus->host_name)<0)
 				return TRUE;
 			else
 				return FALSE;
@@ -3945,7 +3945,7 @@
 				return FALSE;
 		        }
 		else if(s_option==SORT_HOSTNAME){
-			if(strcasecmp(new_svcstatus->host_name,temp_svcstatus->host_name)>0)
+			if(str_domain_compare(new_svcstatus->host_name,temp_svcstatus->host_name)>0)
 				return TRUE;
 			else
 				return FALSE;
@@ -4053,7 +4053,7 @@
 				return FALSE;
 		        }
 		else if(s_option==SORT_HOSTNAME){
-			if(strcasecmp(new_hststatus->host_name,temp_hststatus->host_name)<0)
+			if(str_domain_compare(new_hststatus->host_name,temp_hststatus->host_name)<0)
 				return TRUE;
 			else
 				return FALSE;
@@ -4087,7 +4087,7 @@
 				return FALSE;
 		        }
 		else if(s_option==SORT_HOSTNAME){
-			if(strcasecmp(new_hststatus->host_name,temp_hststatus->host_name)>0)
+			if(str_domain_compare(new_hststatus->host_name,temp_hststatus->host_name)>0)
 				return TRUE;
 			else
 				return FALSE;
diff -urN ../nagios-cvs.orig/common/statusdata.c ./common/statusdata.c
--- ../nagios-cvs.orig/common/statusdata.c	Thu Aug 28 06:07:36 2003
+++ ./common/statusdata.c	Wed Apr 28 17:23:47 2004
@@ -178,6 +178,21 @@
 #endif
 
 
+int str_domain_compare(char *name_a, char *name_b){
+	char *tmp_a, *tmp_b;
+	
+	tmp_a = name_a + strlen(name_a) - 1;
+	tmp_b = name_b + strlen(name_b) - 1;
+
+	while ((tmp_a > name_a || tmp_b > name_b) && strcasecmp(tmp_a,tmp_b) == 0){
+		tmp_a--;
+		tmp_b--;
+		while ((tmp_a > name_a) && *(tmp_a)!=46 ) {tmp_a--;}
+		while ((tmp_b > name_b) && *(tmp_b)!=46 ) {tmp_b--;}
+	}
+	
+	return strcasecmp(tmp_a,tmp_b);
+}
 
 
 
@@ -348,7 +363,7 @@
 	/* add new host status to list, sorted by host name */
 	last_hoststatus=hoststatus_list;
 	for(temp_hoststatus=hoststatus_list;temp_hoststatus!=NULL;temp_hoststatus=temp_hoststatus->next){
-		if(strcmp(new_hoststatus->host_name,temp_hoststatus->host_name)<0){
+		if(str_domain_compare(new_hoststatus->host_name,temp_hoststatus->host_name)<0){
 			new_hoststatus->next=temp_hoststatus;
 			if(temp_hoststatus==hoststatus_list)
 				hoststatus_list=new_hoststatus;
@@ -431,7 +446,7 @@
 	last_svcstatus=servicestatus_list;
 	for(temp_svcstatus=servicestatus_list;temp_svcstatus!=NULL;temp_svcstatus=temp_svcstatus->next){
 
-		if(strcmp(new_svcstatus->host_name,temp_svcstatus->host_name)<0){
+		if(str_domain_compare(new_svcstatus->host_name,temp_svcstatus->host_name)<0){
 			new_svcstatus->next=temp_svcstatus;
 			if(temp_svcstatus==servicestatus_list)
 				servicestatus_list=new_svcstatus;
@@ -440,7 +455,7 @@
 			break;
 		        }
 
-		else if(strcmp(new_svcstatus->host_name,temp_svcstatus->host_name)==0 && strcmp(new_svcstatus->description,temp_svcstatus->description)<0){
+		else if(str_domain_compare(new_svcstatus->host_name,temp_svcstatus->host_name)==0 && str_domain_compare(new_svcstatus->description,temp_svcstatus->description)<0){
 			new_svcstatus->next=temp_svcstatus;
 			if(temp_svcstatus==servicestatus_list)
 				servicestatus_list=new_svcstatus;
diff -urN ../nagios-cvs.orig/include/statusdata.h ./include/statusdata.h
--- ../nagios-cvs.orig/include/statusdata.h	Fri Oct 10 02:18:25 2003
+++ ./include/statusdata.h	Wed Apr 28 17:21:40 2004
@@ -186,6 +186,8 @@
 int update_service_status(service *,int);               /* updates service status data */
 #endif
 
+int str_domain_compare(char *, char *);                 /* compares two strings in a domain-aware manner */
+
 
 #endif
 
