Compares two string values. You can use this function to sort a list of strings
The function returns:
negative number– value of the first argument is lexically less than the second.
positive number– first argument is lexically greater than the second
0 (zero) – arguments are equal
Arguments are coerced to strings, if necessary.
The following expression returns -1.
<cmp> <i>20</i> <i>100</i> </cmp>
The following expression returns -16. This expression returns a number that indicates the difference between the letters r and b when presented in alphabetical order. Since there are 16 letters between the letters b and r, when bob is compared to ray, the value is -16. Alternatively, if r were compared to b, the value returned would be 16.
<cmp> <s>bob</s> <s>ray</s> </cmp>
The following expression returns 0 (zero).
<cmp> <s>daryl</s> <s>daryl</s> </cmp>