52

I am currently reading Pro LINQ c# 2008, and in page 87 the guy says OrderBy and OrderByDescending are stable. But he says exactly the opposite in page 96. It looks to me as he is referring to exactly the same functions, so I don't get it. Are they stable or not?

devoured elysium
  • 101,373
  • 131
  • 340
  • 557

2 Answers2

63

Yes, they're definitely stable. I picked up the same error in my review of the book.

Joe responded to that bit of my review with this:

Just for your reader's knowledge, the ordering is now specified to be stable. Initially it was unstable, and was later changed to be stable but I was told it would be specified to be unstable, but apparently at some point, the specification was changed to be stable. My book was updated but apparently I missed a spot.

So yes, it was a mistake.

Overall it's a reasonably accurate book. (There are a few inaccuracies which are due to MSDN being inaccurate, but that's fairly easy to forgive.) There are far worse around :)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Ah, so funny. Now that I stalked your website I saw you wrote c# in depth, which I am reading too :P – devoured elysium Jul 30 '09 at 23:29
  • If you find any similar mistakes in that, please do let me know :) Unfortunately the errata page on the web site isn't working at the moment, so you can't check whether I already know... – Jon Skeet Jul 30 '09 at 23:31
  • Will there ever be a More C# In Depth? :) – Abhijeet Patel Jul 31 '09 at 02:45
  • The review link you have mentioned doesn't work anymore. It says, *page not found*. Can you update that. – Rahul Feb 27 '16 at 22:32
  • @JonSkeet - The [MSDN](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.orderby?view=netframework-3.5) page for Framework 3.5 (first release of `OrderBy`) says it was stable. Have I misunderstood? – Enigmativity Apr 04 '19 at 08:28
13

According to MSDN, OrderBy is stable, as is OrderByDescending.

Adam Robinson
  • 182,639
  • 35
  • 285
  • 343