I have an IEnumerable that I implemented from Linq2Sql. I have already filtered out the records I want, now I want to order them based on the selected enumeration:
public enum Sort { Time, Name, Value } public class LinqClass { public DateTime Time; public string Name; public double Value; } Sort sort = Sort.Time items.OrderBy(sort);
What is the best way to do this? I could create an overloaded OrderBy (Sort), which is just a big switch statement:
switch(sort) case Time: return this.OrderBy(x=>x.Time);
Perhaps I could do something with the dictionary. Any other ideas, or there is a standard template for this.
source share