diff -Naur nagios-1.2.orig/common/statusdata.c nagios-1.2/common/statusdata.c
--- nagios-1.2.orig/common/statusdata.c	2002-08-19 21:11:28.000000000 -0700
+++ nagios-1.2/common/statusdata.c	2004-07-28 14:45:36.000000000 -0700
@@ -384,6 +384,53 @@
         }
 
 
+/* strpbcmp
+ * Compares strings in phonebook order.
+ * Written by D. Richard Hipp (drh@duke.cs.duke.edu)
+ */
+int strpbcmp(a,b)
+char *a,*b;
+{
+  register int ca, cb;
+  int ai, bi, cnt = 0;
+  int bias = 0;
+
+#ifdef TRACE
+  printf("Comparing \"%s\" to \"%s\" yields ",a,b);
+#endif
+  ca = *(a++);
+  cb = *(b++);
+  while( ca && cb ){
+    if( bias==0 ){
+      if( isupper(ca) ){ ca = tolower(ca); bias--; }
+      if( isupper(cb) ){ cb = tolower(cb); bias++; }
+    }else{
+      if( isupper(ca) ){ ca = tolower(ca); }
+      if( isupper(cb) ){ cb = tolower(cb); }
+    }
+    if( isdigit(ca) ){
+      if( cnt-->0 ){
+        if( cb!=ca ) break;
+      }else{
+        if( !isdigit(cb) ) break;
+        for(ai=0; isdigit(a[ai]); ai++);
+        for(bi=0; isdigit(b[bi]); bi++);
+        if( ai<bi ){ ca=0; break; }
+        if( bi<ai ){ cb=0; break; }
+        if( ca!=cb ) break;
+        cnt = ai;
+      }
+    }else if( ca!=cb ){   break;
+    }
+    ca = *(a++);
+    cb = *(b++);
+  }
+  if( ca==cb ) ca += bias;
+#ifdef TRACE
+  printf("%d\n",ca-cb);
+#endif
+  return ca-cb;
+}
 
 /* adds a host status entry to the list in memory */
 int add_host_status(char *host_name,char *status_string,time_t last_update,time_t last_check,time_t last_state_change,int problem_has_been_acknowledged,unsigned long time_up, unsigned long time_down, unsigned long time_unreachable,time_t last_notification,int current_notification_number,int notifications_enabled,int event_handler_enabled,int checks_enabled,int flap_detection_enabled, int is_flapping, double percent_state_change, int scheduled_downtime_depth, int failure_prediction_enabled, int process_performance_data, char *plugin_output){
@@ -510,7 +557,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(strpbcmp(new_hoststatus->host_name,temp_hoststatus->host_name)<0){
 			new_hoststatus->next=temp_hoststatus;
 			if(temp_hoststatus==hoststatus_list)
 				hoststatus_list=new_hoststatus;
@@ -729,7 +776,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(strpbcmp(new_svcstatus->host_name,temp_svcstatus->host_name)<0){
 			new_svcstatus->next=temp_svcstatus;
 			if(temp_svcstatus==servicestatus_list)
 				servicestatus_list=new_svcstatus;
@@ -738,7 +785,7 @@
 			break;
 		        }
 
-		else if(strcmp(new_svcstatus->host_name,temp_svcstatus->host_name)==0 && strcmp(new_svcstatus->description,temp_svcstatus->description)<0){
+		else if(strpbcmp(new_svcstatus->host_name,temp_svcstatus->host_name)==0 && strpbcmp(new_svcstatus->description,temp_svcstatus->description)<0){
 			new_svcstatus->next=temp_svcstatus;
 			if(temp_svcstatus==servicestatus_list)
 				servicestatus_list=new_svcstatus;
