title: C#: Sorting with anonymous function
body: <p>Let's say I have a list of objects, and I want to sort it by the items DateModified property. Why can't I use a delegate like this? How should I sort these by DateModified if not as shown below:</p>
  
  <pre><code>public string SortByDateModified(List&lt;CartItem&gt; items)
  {
      items.Sort(new Func&lt;CartItem, CartItem, bool&gt;((itemA, itemB) =&gt;
      {
          return itemA.DateModified &lt; itemB.DateModified;
      }));
  }
  </code></pre>