title: C# object sorting by group, using linq
body: <p>I have a list of objects which are grouped by a particular property.  I need to sort this list based on other properties, but it always needs to retain the grouping.  So for example, if the list is something like:</p>
  
  <pre><code>{ id=1, partNumber = 100 }
  { id=2, partNumber = 500 }
  { id=2, partNumber = 300 }
  { id=2, partNumber = 600 }
  { id=3, partNumber = 550 }
  { id=3, partNumber = 990 }
  { id=4, partNumber = 200 }
  { id=5, partNumber = 300 }
  </code></pre>
  
  <p>then the result after sorting by part number ascending would be:</p>
  
  <pre><code>{ id=1, partNumber = 100 }
  { id=4, partNumber = 200 }
  { id=5, partNumber = 300 }
  { id=2, partNumber = 400 }
  { id=2, partNumber = 500 }
  { id=2, partNumber = 600 }
  { id=3, partNumber = 550 }
  { id=3, partNumber = 990 }
  </code></pre>
  
  <p>It sorts by the minimum PartNumber in each group (or maximum if the sort is descending), but must remain grouped by ID.  I have tried various combinations of .OrderBy() and .GroupBy(), but I can't seem to get what I need.</p>