When I sorted a vector of slices I was baffled by the result:
let mut v = [ "zoo", "a dog", "Zoology", "Anton" ];
v.sort();
println!("sorted: {:?}", v);
sorted: ["Anton", "Zoology", "a dog", "zoo"]
I had assumed
sorted: ["a dog", "Anton", "zoo", "Zoology"]
like the sort
command would do.
Then I discovered why things are like this.
The sort
commands respects the locale settings whereas the Rust sort does not.
So, if I run: LC_ALL=C sort testfile
the result is the same as in Rust sort.
Question: How do I tell the Rust sort to respect the locale settings?