I am litle curious about what sorting algorithm is using OrderBy (linq to objects). quicksort? heapsort? introspective sort ?

As i see in MSDN documentation List.Sort is using introspective sort: see: http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspx

Maybe OrderBy use the same?

If we go to order by documetation i don't see much information: http://msdn.microsoft.com/en-us/library/system.linq.enumerable.orderby(v=vs.110).aspx

  • Two very related posts on SO here (About LINQ based Sorting) and here (About Array data type sorting) – RBT Aug 23 '17 at 2:17

Apparently it uses a stable quicksort.

This has been verified using reflector.

See: https://stackoverflow.com/a/2792105/569777

  • could be, sadly was ansewered 2 years. As i can see it, the implementation from one version to another version of framework could be different (example: array.sort from fm2 was quicksort and for the fm4.5 is introspective sort ) – Rolando Dec 13 '13 at 21:01
  • 2
    Reflector is your friend :) – MetaFight Dec 13 '13 at 21:02
  • @MetaFight There are also free alternatives, like dotPeek. – svick Dec 13 '13 at 21:50
  • True. I keep forgetting it isn't free anymore. – MetaFight Dec 13 '13 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.