Rust collections cross as plain JavaScript values: a Vec is an array, a map with string keys is an object, and bytes are a Uint8Array.
sorted takes an array and returns one, and word_lengths returns a BTreeMap, which arrives as an object keyed by its strings. Each is a deep copy: JavaScript and Rust share no collection.
invert reads its &[u8] from a Uint8Array and returns a Vec<u8>, which arrives as a new Uint8Array. &[f64] and Vec<f64> cross the same way, as a Float64Array.
Try it
Sort another list, then invert the inverted bytes to get the first array back.