LINQ OrderBy not ordering .. changing nothing .. why?

Don’t throw away the return value. The OrderBy extension method is does not mutate the input. Try:

newView = newView.OrderBy(x => x.viewed);

There is no reason why that won’t work, assuming the viewed value is correct. Also, make sure that OrderBy is after any operations (e.g. Distinct) which will ruin ordering.

Happy coding!

Leave a Comment