score:1

Accepted answer

Seems that there isn't much of an answer to be made, so:

As pointed by SLaks the issue has been known for a long time but has never been fixed in the .NET Framework despite all the new releases (.Net 4.6.1 as of now) - https://connect.microsoft.com/VisualStudio/feedback/details/634949/orderbydescending-fails-in-linq-to-objects-when-a-comparer-returns-int-minvalue.

The only way to avoid this problem is to not return the Int32.MinValue from CompareTo implementations.


But as pointed by usr .Net Core has this issue fixed - https://github.com/dotnet/corefx/blob/35e03c78d89d02f2d3b4a1f8b277a35c88f45750/src/System.Linq/src/System/Linq/OrderedEnumerable.cs#L628


Related Articles