+/*************************************************
+* Sort addresses when testing *
+*************************************************/
+
+/* This function is called only when running in the test harness. It sorts a
+number of multihomed host IP addresses into the order, so as to get
+repeatability. This doesn't have to be efficient. But don't interchange IPv4
+and IPv6 addresses!
+
+Arguments:
+ host -> the first host item
+ last -> the last host item
+
+Returns: nothing
+*/
+
+static void
+sort_addresses(host_item *host, host_item *last)
+{
+BOOL done = FALSE;
+while (!done)
+ {
+ host_item *h;
+ done = TRUE;
+ for (h = host; h != last; h = h->next)
+ {
+ if ((Ustrchr(h->address, ':') == NULL) !=
+ (Ustrchr(h->next->address, ':') == NULL))
+ continue;
+ if (Ustrcmp(h->address, h->next->address) > 0)
+ {
+ uschar *temp = h->address;
+ h->address = h->next->address;
+ h->next->address = temp;
+ done = FALSE;
+ }
+ }
+ }
+}
+
+
+