The
compare function compares the two strings expressions
string1 and
string2 character by character to determine the alphabetical (collating sequence) order of the strings. If
string1 and
string2 are of different lengths, the function will pad the shorter string with blanks to carry out the comparison.
The function returns an integer value of:
-1 | if string1 would be listed alphabetically before string2. |
0 | if the strings are identical. |
1 | if string1 would be listed alphabetically after string2. |
Direct string comparisons can also be made. For example, the following code is permissible: