Comp()
FUNCTION: comp(<string1>, <string2>, <type>)
Compares two strings and returns 0 if they are equal, -1 if <string1> precedes <string2>, and 1 if <string1> follows <string2>.
By default, comp() uses Unicode collation (UCA) which provides linguistically correct ordering for all scripts and languages.
The optional <type> argument selects the comparison mode:
u - Unicode collation (default). Full case-sensitive comparison
using the Unicode Collation Algorithm with primary, secondary,
and tertiary weight levels.
c - Case-insensitive Unicode collation. Uses only primary and
secondary weights, so 'Hello' and 'hello' compare as equal.
a - Legacy ASCII comparison (byte-order strcmp).
Examples:
> say comp(abc, abd)
You say, "-1"
> say comp(Hello, hello)
You say, "-1"
> say comp(Hello, hello, c)
You say, "0"
> say comp(café, cafe)
You say, "1"
Related Topics: sort(), setunion(), setinter(), setdiff().