[Mono-bugs] [Bug 442257] System.Array.Sort produces wrong results

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Nov 11 08:35:02 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=442257

User alan.mcgovern at gmail.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=442257#c4





--- Comment #4 from Alan McGovern <alan.mcgovern at gmail.com>  2008-11-11 06:35:01 MST ---
This makes my previous attempt at a fix wrong then. They must be doing
x.CompareTo (x) != 1.

In short: You should expect undefined behaviour when the IComparer is invalid.
You will get different behaviour depending on what class is doing the sorting,
even on the same framework.

The problem is class X might do:

public void Sort ()
{
    if (compare (array[i], array[i+1]) > 1)
          Swap (i, i+1);
}

and class Y will do:

public void Sort ()
{
    if (compare (array[i], array[i-1]) > 1)
          Swap (i, i-1);
}

When you swap the order, you change the outcome. I'm marking the previous patch
as invalid because it doesn't have the same behaviour as MS.NET.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list