What I used to do is create a case switch that sorts my LINQ in this format:
List<products> productList = GetAllLists();
switch (sortBy)
{
case "name":
return productsList.OrderBy(pl => pl.Name);
case "date":
return productsList.OrderBy(pl => pl.DateCreate);
}
which, in the long run, becomes cumbersome.
I wanted to have a generic method that you simply use to sort out List collections like these and will help you toggle which property to sort by.. something like this:
return SortListCollection(productsList, Name);