4 ms·
What is an "ordinal string comparison"? To contrast, what is a non-ordinal string comparison?
by afdsafsfasd 5y ago
What is an "ordinal string comparison"? To contrast, what is a non-ordinal string comparison?
- ChrisSD 5y agoA string is encoded in memory as an array of numbers so in this case "ordinal" means that it simply compares the two arrays number by number. A non-ordinal string comparison may take into account other things such as iterating by actual characters and comparing them in language and culture-aware ways. This is useful for ordering things by name when showing a list to users.
- Thiez 5y agoOrdinal compares the literal bytes. The other comparison variants have additional features, e.g. case-insensitivity.
- deleted 5y ago[deleted]
- AtNightWeCode 5y agoOrdinal is plain binary comparison. The default comparison takes language specifics into account. For instance, in German there is a letter called Eszett (ß) that stands for "ss". IndexOf("ss") will find that.
- dgellow 5y agoIn Germany's German "ss" and "ß" are two different things, ß is its own letter and its transliteration is "ss" or "sz". But it really is its own thing and is not equivalent to "ss". In the past "SS" was the capitalized version of "ß", but that's not officially the case anymore, you now have a capitalized ẞ [0], even if it isn't used in practice (or if it is, really not often). It's not the same for all versions of German though. For example in Swiss German ß is not used and is replaced by "ss". I do not know about Austrian German but I would not be surprised if they have some specificities around the letter ß. In short: it's complicated :) [0]: https://de.wikipedia.org/wiki/Gro%C3%9Fes_%C3%9F https://de.wikipedia.org/wiki/Gro%C3%9Fes_%C3%9F