public class SortExample
{
public int IntField {get; set;}
public string StringField {get; set;}
public DateTime DateField {get; set;}
}
This class is set as a source for a listview and the sortExpression param passed in function below is property name with sort order 'IntField ASC' 'IntField DESC' 'StringField ASC' 'StringField DESC'
public void SortExampleMethod(string sortExpression)
{
List<SortExample> list = new List<SortExample>();
list.OrderBy(sortExpression);
}
Is the only way to implement this is to write a Comparator for every property or something in LINQ allows this to be done easily?