2010-03-24 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Wed, 24 Mar 2010 17:39:19 +0000 (17:39 -0000)
committerJb Evain <jbevain@gmail.com>
Wed, 24 Mar 2010 17:39:19 +0000 (17:39 -0000)
* SortSequenceContext.cs: Fix OrderByDescending stability.
Based on a patch by Richard Kiene  <richard.kiene@logos.com>.

svn path=/trunk/mcs/; revision=154154

mcs/class/System.Core/System.Linq/ChangeLog
mcs/class/System.Core/System.Linq/SortSequenceContext.cs

index a7c2221dc4c4ff1628402522e411c66580f2a397..0438c8dd5732119845b4e430893a91c61d65a421 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-24  Jb Evain  <jbevain@novell.com>
+
+       * SortSequenceContext.cs: Fix OrderByDescending stability.
+       Based on a patch by Richard Kiene  <richard.kiene@logos.com>.
+
 2010-02-23  Marek Safar  <marek.safar@gmail.com>
 
        * Enumerable.cs: Implement Zip.
index 2ec42114a4105d8c26865a31216a0db16b214869..a25427e60cbce19b2f6b5c60f8d89b09d3a4042f 100644 (file)
@@ -62,8 +62,10 @@ namespace System.Linq {
                        if (comparison == 0) {
                                if (child_context != null)
                                        return child_context.Compare (first_index, second_index);
-                               else
-                                       comparison = first_index - second_index;
+
+                               comparison = direction == SortDirection.Descending
+                                       ? second_index - first_index
+                                       : first_index - second_index;
                        }
 
                        return direction == SortDirection.Descending ? -comparison : comparison;