You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array.Sort ( .NET 5.0 Preview 7 ) generates wrong result for a sample data set. #41235
Array.Sort(sample) ( .NET 5.0 Preview 7 ) generates wrong result for a sample data set.
The sample data set is a string[] with the Namespaces for each Type in .NET.
This is 8500+ items, including a lot of nulls and repetitions.
I did a short test by modification of the current Array.Sort code in the .NET Core Source Browser.
I removed the PartitionSort part and left only the HeapSort for the entire sort.
With the HeapSort the result is correct.
Using Visual Studio 2019 version 16.8 with .NET 5.0 Preview 7.
I can provide the sample data set if that helps.
This is a simplification of the code that demonstrates the issue:
Type[] t1 = f1();
int max = t1.Length;
string[] m1 = new string[max];
for (var n = 0; n < max; n++) m1[n] = t1[n].Namespace;
Array.Sort(m1);
f1() is a function that extracts by reflection a list of most of the Types in the .NET (core and desktop Types).
I can provide this function f1() but it is basically a loop in all the .NET assemblies using the function GetTypes() for each assembly.
The attached zip contains 4 text files extracted from the Value column of the Debug (using "Copy Value")
Sort_issue_1 contains all the 8500+ values of string[] m1 array.
Sort_issue_2 contains all the 8500+ values of m1 after the Array.Sort(m1).
Sort_issue_3 contains all the 8500+ values of m1 after the HeapSort(m1).
Sort_issue_4 contains a sample of the first 500 values of Type[] t1.
Activity
svick commentedon Aug 23, 2020
Yes, can you provide a complete example code that demonstrates the issue? Also, can you explain what makes the result wrong?
MarcioAB commentedon Aug 23, 2020
This is a simplification of the code that demonstrates the issue:
Type[] t1 = f1();
int max = t1.Length;
string[] m1 = new string[max];
for (var n = 0; n < max; n++) m1[n] = t1[n].Namespace;
Array.Sort(m1);
f1() is a function that extracts by reflection a list of most of the Types in the .NET (core and desktop Types).
I can provide this function f1() but it is basically a loop in all the .NET assemblies using the function GetTypes() for each assembly.
The attached zip contains 4 text files extracted from the Value column of the Debug (using "Copy Value")
Sort_issue_1 contains all the 8500+ values of string[] m1 array.
Sort_issue_2 contains all the 8500+ values of m1 after the Array.Sort(m1).
Sort_issue_3 contains all the 8500+ values of m1 after the HeapSort(m1).
Sort_issue_4 contains a sample of the first 500 values of Type[] t1.
Sort_Issue.zip
What makes the result wrong?
Look at the file Sort_issue_2.txt, which contains the results after the sort, clearly shows there is something wrong.
svick commentedon Aug 23, 2020
You're right, it is a bug. I'm in the process of submitting a Pull Request that should fix it.
Dotnet-GitSync-Bot commentedon Aug 23, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
jkotas commentedon Aug 23, 2020
Keep open to track release/5.0 backport
jeffhandley commentedon Aug 26, 2020
This was backported to
release/5.0with #41239.