Sort module

compare_strings

procedure · 1 overloadSource

A three-way comparator for strings, -1, 0 or 1, comparing bytes in order, so UTF-8 text sorts by code point and upper case comes before lower case. A string that is a prefix of another goes first.

ExampleOpen in playground ↗
names := string.["pear", "Apple", "fig", "figs"];
quick_sort(names, compare_strings);
assert(names[0] == "Apple" && names[1] == "fig" && names[2] == "figs" && names[3] == "pear");
compare_strings :: (a: string, b: string) -> s64

Parameters

a: string
b: string

Returns

s64

See also