Issue 23 in linqbridge: Nondeterministic keySelector in OrderBy

1 view
Skip to first unread message

linqb...@googlecode.com

unread,
May 31, 2011, 5:50:07 AM5/31/11
to linqbridg...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 23 by ilya.ind...@gmail.com: Nondeterministic keySelector in
OrderBy
http://code.google.com/p/linqbridge/issues/detail?id=23

Hi,

There is a difference in the implementation of OrderedEnumerable, which
affects the way how keySelector is threated.

Consider the following example:

[Test]
public void OrderByNonDeterministic()
{
var values = "abcd".ToCharArray();
int key = values.Count();
values = values.OrderBy(_ => key--).ToArray();

Assert.AreEqual("dcba", new String(values));
Assert.AreEqual(0, key, "Key for every element is computed only
once");

}

keySelector is evaluated only once for each element in System.Core, and
then resulting key array is sorted.
As an opposite in LinqBridge keySelector is computed for every two elements
being compared. So it produces different result. Even for deterministic
keySelector this can hurt performance.

According to the documentation of OrderBy there are no limitations to the
keySelector function, except that Comparer<TKey>.Default must exist for key
values being returned, if such comparer isn't provided for OrderBy.


linqb...@googlecode.com

unread,
Apr 16, 2012, 7:08:56 AM4/16/12
to linqbridg...@googlegroups.com
Updates:
Status: Accepted
Owner: azizatif
Labels: Milestone-Release1.3

Comment #1 on issue 23 by azizatif: Nondeterministic keySelector in OrderBy
http://code.google.com/p/linqbridge/issues/detail?id=23

(No comment was entered for this change.)

linqb...@googlecode.com

unread,
Apr 16, 2012, 1:07:33 PM4/16/12
to linqbridg...@googlegroups.com
Updates:
Status: Fixed

Comment #2 on issue 23 by azizatif: Nondeterministic keySelector in OrderBy
http://code.google.com/p/linqbridge/issues/detail?id=23

This issue was closed by revision b09ed8a618f6.

Reply all
Reply to author
Forward
0 new messages