Compare()
Performs a case-sensitive comparison of two strings. Returns:
-1if string1 is less than string20if string1 is equal to string21if string1 is greater than string2
Compare( string1=string, string2=string );
Returns: Number
| Argument | Description |
|---|---|
|
string1
string,
required
|
edit
A string or a variable that contains one |
|
string2
string,
required
|
edit
A string or a variable that contains one |
Examples
editdump(Compare("100 Main St.", "675 East Avenue")); // -1
dump(Compare("500 Main St.", "1 Cupertino Way")); // 1
dump(Compare("500 Main St.", "500 Main St."));//0
See also
- Strings
- string.compare()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)