I am trying to find the smallest lexicographic string in a vector of strings in rust (rust equivalent of python min(strings)
). However, I am not sure how I would be able to compare strings lexicographically with rust in the first place. How would I go about doing so?
It seems like comparison with the <
or >
works, but I am not sure if that is actually true lexicographic comparison.
impl Ord for str
Strings are ordered lexicographically by their byte values. This orders Unicode code points based on their positions in the code charts. This is not necessarily the same as “alphabetical” order, which varies by language and locale. Sorting strings according to culturally-accepted standards requires locale-specific data that is outside the scope of the
str
type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With