Compare()

Performs a case-sensitive comparison of two strings. Returns:

  • -1 if string1 is less than string2
  • 0 if string1 is equal to string2
  • 1 if string1 is greater than string2
Compare( string1=string, string2=string );

Returns: Number

Argument Description
string1
string, required

A string or a variable that contains one

string2
string, required

A string or a variable that contains one

Examples

dump(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