Hello
The default sorting for string uses String.Compare which is slow because it
uses culture information to compare string.
Better use String.CompareOrdinal if you use english strings only or don't
want culture specific sorting.
Best regards
Sherif
> Hi !
>
[quoted text clipped - 7 lines]
> thanks,
> nick
> Does anyone know when there will be a faster
> implementation of Sorting in c#, because sorting
> of only 300 Strings is extremly slow. And implementing
> sorting for objects via CompareTo is also much too
> slow because you have to cast the object to access
> the member which is to be sorted.
Casting is pretty fast. If you need to box/unbox, that takes a lot
longer.
When you say that sorting 300 strings is "extremely slow", what exactly
do you mean? As another poster mentioned, using CompareOrdinal speeds
things up considerably - on my machine I can sort an array of 300
strings 100,000 times in 10 seconds, which certainly doesn't sound
"extremely slow" to me.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Gang Peng[MSFT] - 19 Nov 2003 19:59 GMT
Yes. If you don't care about cultural issues, you should try ordinal
comparison as Jon suggested.
Generics will solve the problems of boxing/unboxing and casting, but you
need to wait for Whidbey.
Gang Peng
[MS]