Hi everyone!
I'm having a little problem when sorting the ArrayList and I was
wondering if there is a .NET guru who can help me out :)
I'm trying to sort ArrayList alphabetically in ASP.Net -page using the
ArrayList.Sort(), but I not getting the results sorted properly.
I'm having problems especially with the scandic characters although
CurrentCulture is set to Finnish, which should handle these charcters
properly.
Thanks :)
Jarkko
Here is the code for the comparision I'm using currently...
internal class MyComparer : IComparer
{
public int Compare(object x, object y)
{
CultureInfo originalCulture =
System.Threading.Thread.CurrentThread.CurrentCultu re;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
try
{
String sx = x as String;
String sy = y as String;
if (sx != null && sy != null)
return String.Compare(sx, sy);
else
return Comparer.Default.Compare(x,y);
}
finally
{
Thread.CurrentThread.CurrentCulture = originalCulture;
}
}
}