views:

232

answers:

3

Evidently LINQ's "OrderBy" had originally been specified as unstable, but by the time of Orca it was specified as stable. Not all documentation has been updated accordingly - consider these links:

But if LINQ's OrderBy is now "stable," then it means it is not using a quicksort (which is inherently unstable) even though some documentation (e.g. Troy's book) says it is. So my question is: if not quicksort, then what is the actual algorithm LINQ's orderBy is using?

A: 

I am under the understanding that OrderBy gets translated into SQL that performs the sort on the Database. At least in the case of LINQ to SQL

John Weldon
Yes, but that's only true for Linq to SQL and other database Linq providers. Linq is not just an ORM... (Linq to Objects, Linq to XML...)
Thomas Levesque
+5  A: 

Boot up reflector, open to System.Linq.EnumerableSorter reveals that Linq2Objects uses the quick sort

LorenVS
+1 for looking it up
Thomas Levesque
+1 for looking it up
helios456
+7  A: 

For LINQ to Objects, it's a stable quicksort that is used. For any other kind of LINQ, it's left to the underlying implementation.

Jb Evain