Antonio said:
Hello. I have tried to insert this items into a SortedList.
dic = New SortedList
dic.Add("<<", "<<")
dic.Add("==", "==")
dic.Add(">>", ">>")
dic.Add("@@", "@@")
dic.Add("??", "??")
Debugging this peace of code I have notice that '??' appears as first item,
then '@@', etc...Ascii codes for '?' and '@' are greater than '<' '=' '>'.
May be this is a bug or an undocumented behavior ??
Your keys are strings so the sorting order is determined by the
IComparable implementation in the string class. The sort may not be an
ASCII sort, depending on the CurrentCulture used.
From the docs on the string class:
"Sort rules determine the alphabetic order of Unicode characters and
how two strings compare to each other. For example, the Compare method
performs a linguistic comparison while the CompareOrdinal method
performs an ordinal comparison. Consequently, if the current culture is
U.S. English, the Compare method considers 'a' less than 'A' while the
CompareOrdinal method considers 'a' greater than 'A'.
The .NET Framework supports word, string, and ordinal sort rules. A
word sort performs a culture-sensitive comparison of strings in which
certain nonalphanumeric Unicode characters might have special weights
assigned to them. For example, the hyphen ("-") might have a very small
weight assigned to it so that "coop" and "co-op" appear next to each
other in a sorted list. A string sort is similar to a word sort, except
that there are no special cases and all nonalphanumeric symbols come
before all alphanumeric Unicode characters. An ordinal sort compares
strings based on the numeric value of each Char in the string. For more
information about word, string, and ordinal sort rules, see the
System.Globalization.CompareOptions topic."