[SOLVED] linq orderby.tolist() performance


I have an ordering query to a List and calling for many times.
list = list.OrderBy().ToList();
In this code ToList() method is spending high resources and takes very long time. How can I speed up with another ordering method without converting back to a list. Should I use .Sort extension for arrays?


First of all, try to sort the list once, and keep it sorted.

To speed up things you can use Parallel LINQ.

see: http://msdn.microsoft.com/en-us/magazine/cc163329.aspx

An OrderBy() Parallel looks like this:

 var query = data.AsParallel().Where(x => p(x)).Orderby(x => k(x)).ToList();

Answered By – CaptainPlanet

Answer Checked By – Cary Denson (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *