MINOR: tools: add strordered() to check whether strings are ordered

When trying to sort sets of strings, it's often needed to required to
compare 3 strings to see if the chosen one fits well between the two
others. That's what this function does, in addition to being able to
ignore extremities when they're NULL (typically for the first iteration
for example).
diff --git a/include/haproxy/tools.h b/include/haproxy/tools.h
index 1a17515..6e3848f 100644
--- a/include/haproxy/tools.h
+++ b/include/haproxy/tools.h
@@ -915,6 +915,8 @@
 /* same as strstr() but case-insensitive */
 const char *strnistr(const char *str1, int len_str1, const char *str2, int len_str2);
 
+int strordered(const char *s1, const char *s2, const char *s3);
+
 /* after increasing a pointer value, it can exceed the first buffer
  * size. This function transform the value of <ptr> according with
  * the expected position. <chunks> is an array of the one or two
diff --git a/src/tools.c b/src/tools.c
index 34f8632..5d5e1b0 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -4363,6 +4363,15 @@
 	return NULL;
 }
 
+/* Returns true if s1 < s2 < s3 otherwise zero. Both s1 and s3 may be NULL and
+ * in this case only non-null strings are compared. This allows to pass initial
+ * values in iterators and in sort functions.
+ */
+int strordered(const char *s1, const char *s2, const char *s3)
+{
+	return (!s1 || strcmp(s1, s2) < 0) && (!s3 || strcmp(s2, s3) < 0);
+}
+
 /* This function read the next valid utf8 char.
  * <s> is the byte srray to be decode, <len> is its length.
  * The function returns decoded char encoded like this: