OrderByDescending should preserve order of two same keys

Jul 29, 2012 at 6:02 AM
Edited Jul 29, 2012 at 6:07 AM

I found a diffrent hehavior of linq.js from original LINQ.

OrderByDescending operator of linq.js reverse the two elements which have same keys. This does not follow the below behavior detail. "if the keys of two elements are equal, the order of the elements is preserved."

 

linq.js v2.2.0.2 and v3.0.1-beta (suppose that method names are in lowerCamelCase)

Enumerable
.From([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
.OrderByDescending("$%5")
// will return [9, 4, 8, 3, 7, 2, 6, 1, 10, 5]

LINQ (tested on LINQPad 4.42.01)

new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
.OrderByDescending(i => i%5)
// will return [4, 9, 3, 8, 2, 7, 1, 6, 5, 10]
Coordinator
Jul 29, 2012 at 12:24 PM

Thank you.

yes, it is bug of linq.js.

I fixed http://linqjs.codeplex.com/SourceControl/changeset/e30c38e4d170