Orders two strings byte by byte: -1 when a sorts first, 1 when b does, 0 when they are equal.
compare :: (a: string, b: string) -> int
A string that is a prefix of another sorts first. Bytes compare as unsigned numbers, so the order is not locale aware and UTF-8 text sorts by code point.
Parameters
- a: string
- b: string
Returns
- int
assert(compare("apple", "banana") == -1);
assert(compare("b", "a") == 1);
assert(compare("ab", "ab") == 0);
assert(compare("a", "ab") == -1);