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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.