title: Remove duplicates from a List<T> based on a condition in C#
body: <p>I have a List of an object (exobject in the below code sample) who each have SomeId, AnotherId, SomeOtherId and Timestamp. This list might have duplicate entries with each record having a different Timestamp.
  I want to remove all duplicates of this object with older Timestamps and only keep those that are the latest. </p>
  
  <p>Sample object:</p>
  
  <pre><code>SomeId    AnotherId    SomeOtherId    Timestamp
  1         2            1              10
  1         2            1              20
  1         3            2              30
  2         3            4              40
  1         3            2              50
  </code></pre>
  
  <p>My required list should be</p>
  
  <pre><code>1,2,1,20 and 1,3,2,50 and 2,3,4,40.
  </code></pre>
  
  <p>I have a very crude implementation in C# do do this.</p>
  
  <pre><code>for (int i = 0; i &lt; exObject.Count - 1; i++)
  {
      for (int j = i + 1; j &lt; exObject.Count - 1; j++)
      {
          if (exObject[i].SomeId == exObject[j].SomeId &amp;&amp; exObject[i].AnotherId == exObject[j].AnotherId &amp;&amp; exObject[i].SomeOtherId == exObject[j].SomeOtherId)
           {
               if (exObject[i].TimeStamp &lt; exObject[j].TimeStamp)
                   exObject[i].TimeStamp = exObject[j].TimeStamp;
               exObject.Remove(exObject[j]);
           }
      }
  }
  </code></pre>
  
  <p>I would like to know if there is a more elegant and nicer way to do this or if there is a lambda I can use to accomplish this.</p>