title: Sorting a list using Lambda/Linq to objects
body: <p>I have the name of the "sort by property" in a string. I will need to use Lambda/Linq to sort the list of objects.</p>
  
  <p>Ex:</p>
  
  <pre><code>public class Employee
  {
    public string FirstName {set; get;}
    public string LastName {set; get;}
    public DateTime DOB {set; get;}
  }
  
  
  public void Sort(ref List&lt;Employee&gt; list, string sortBy, string sortDirection)
  {
    //Example data:
    //sortBy = "FirstName"
    //sortDirection = "ASC" or "DESC"
  
    if (sortBy == "FirstName")
    {
      list = list.OrderBy(x =&gt; x.FirstName).toList();    
    }
  
  }
  </code></pre>
  
  <ol>
  <li>Instead of using a bunch of ifs to check the fieldname (sortBy), is there a cleaner way of doing the sorting</li>
  <li>Is sort aware of datatype?</li>
  </ol>