Why does the Linq OrderBy extension not affect the list it is called on?

It's a different list. The ToList() call creates a new ListYou can start reading about it here.

It's a different list. The ToList() call creates a new List instance, entirely separate from the List that was passed into the method. It will have the same items in it, probably in a different order, but the list itself is a different object.By the way, dynamic linq already does this so you might want to check it out.

You can start reading about it here.

Exactly. Which is as expected. Realistically you would want to pass in an IQueryable and return an IQueryable as well.

– Keltex Jul 8 at 19:04 Yeah, this is essentially what I want. Thanks for the tip! – IronicMuffin Jul 8 at 19:39.

If you want to modify the original list, use List.Sort.

One of the basic ideas behind LINQ is that it does not modify the things its called on. OrderBy() can be called on any IEnumerable, even those that aren't backed by anything resembling a list (e.g. It's generated on the fly). And it would be really inconsistent if it did something like: “If the source is IList, sorts it and returns the original reference.

If it doesn't, creates a new sorted sequence. €?.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions