[Mono-bugs] [Bug 616416] New: Array.Sort() doesnt sort
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Jun 22 15:27:11 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=616416
http://bugzilla.novell.com/show_bug.cgi?id=616416#c0
Summary: Array.Sort() doesnt sort
Classification: Mono
Product: Mono: Runtime
Version: SVN
Platform: 64bit
OS/Version: RHEL 5
Status: NEW
Severity: Major
Priority: P5 - None
Component: misc
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: srfcanada at hotmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64;
Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152)
The given sample test gives different results under windows .net and mono. Note
that it seems to have something to do with IComparer. If you explicitly change
the comparer to null in the Sort method it will work but in both cases the
comparer is null which is the really strange thing.
Reproducible: Always
Steps to Reproduce:
Run the following Test under windows .net and mono it will generate different
results:
public class SortClass<T> where T : IComparable<T>
{
public void Sort(T[] values, IComparer comparer)
{
T[] doubleValues = new T[11];
doubleValues[0] = values[0];
doubleValues[1] = values[1];
doubleValues[2] = values[2];
doubleValues[3] = values[3];
doubleValues[4] = values[4];
doubleValues[5] = values[5];
doubleValues[6] = values[6];
doubleValues[7] = values[7];
doubleValues[8] = values[8];
doubleValues[9] = values[9];
doubleValues[10] = values[10];
int[] indices = new int[11];
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 3;
indices[4] = 4;
indices[5] = 5;
indices[6] = 6;
indices[7] = 7;
indices[8] = 8;
indices[9] = 9;
indices[10] = 10;
//the comparer passed in is null
//try changing the comparer to null and see how the sorting is
changed even though
//both times the comparer is really null, kind of strange
Array.Sort(doubleValues, indices, comparer);
foreach (T doubleValue in doubleValues)
{
Console.WriteLine("DoubleValue: " + doubleValue);
}
foreach (int index in indices)
{
Console.WriteLine("IndexValue: " + index);
}
}
}
[Test]
public void testSort()
{
double[] doubleValues = new double[11];
doubleValues[0] = 0.221788066253601;
doubleValues[1] = 0.497278285809481;
doubleValues[2] = 0.100565033883643;
doubleValues[3] = 0.0433309347749905;
doubleValues[4] = 0.00476726438463812;
doubleValues[5] = 0.1354609735456;
doubleValues[6] = 0.57690356588135;
doubleValues[7] = 0.466239434334826;
doubleValues[8] = 0.409741461978934;
doubleValues[9] = 0.0112412763949565;
doubleValues[10] = 0.668704347674307;
SortClass<double> sortClass = new SortClass<double>();
sortClass.Sort(doubleValues,null);
}
--
Configure bugmail: http://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