[Mono-devel-list] [PATCH] make String.Compare trasitive
Miguel de Icaza
miguel at ximian.com
Thu Oct 9 13:27:53 EDT 2003
Hello,
>
> This code causes lowercase letters to be always smaller then uppercase
> letters (against ASCII order). Anyway the problem is that this causes
> String.Compare not to be transitive. For example:
>
> "_" < "a" < "A"
>
> But:
>
> "_" > "A"
>
> Non-transitive comparison function causes problems for tree-like
> data structures using it, and for sorting algorithms (some versions of
> qsort() will for example crash).
>
> I understand that this is going to be fixed some day (TODO), but as for
> now maybe it would be better to treat normal comparison as ordinal (i.e.
> remove the check for upper-lower case).
I researched this topic, and the result is correct.
This is actually pointed out in the String.Compare method description
(and we should document it ourselves as well).
If you want the other kind of compares, you should use
String.CompareOrdinal that will give the effect you want.
Miguel
More information about the Mono-devel-list
mailing list