From 23ca78329600ba76edafa8c571f4d5873709f56c Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Tue, 22 Jul 2003 20:01:53 +0000
Subject: [PATCH] Re-sort hostlist for each record after shifting a value off
 and replacing it to put the records in hostlist order if so requested.

---
 src/sinfo/sort.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/sinfo/sort.c b/src/sinfo/sort.c
index 9fd7c1ab3fb..218b53d78dd 100644
--- a/src/sinfo/sort.c
+++ b/src/sinfo/sort.c
@@ -263,18 +263,20 @@ static int _sort_by_node_list(void *void1, void *void2)
 	int inx;
 #endif
 
-	hostlist_sort(sinfo1->nodes);
-	hostlist_sort(sinfo2->nodes);
 	val1 = hostlist_shift(sinfo1->nodes);
-	if (val1)
+	if (val1) {
 		hostlist_push_host(sinfo1->nodes, val1);
-	else
+		hostlist_sort(sinfo1->nodes);
+	} else
 		val1 = "";
+
 	val2 = hostlist_shift(sinfo2->nodes);
-	if (val2)
+	if (val2) {
 		hostlist_push_host(sinfo2->nodes, val2);
-	else
+		hostlist_sort(sinfo2->nodes);
+	} else
 		val2 = "";
+
 #if	PURE_ALPHA_SORT
 	diff = strcmp(val1, val2);
 #else
-- 
GitLab