Skip to main content

utf16_order

Function utf16_order 

Source
pub fn utf16_order(left: &str, right: &str) -> Ordering
Expand description

What: Order names as JavaScript’s < does, by UTF-16 code units. std::cmp::Ordering is less, equal or greater. Why: Rust compares Strings by UTF-8 bytes, which orders characters above U+FFFF differently from characters between U+E000 and U+FFFF.

In TS you’d write (pseudocode):

const byName = (left: string, right: string) => (left < right ? -1 : left > right ? 1 : 0);