title: Create a new list in C# with LINQ, sorted by type and ignoring objects of the same type if they occur more than once
body: <p>I have a list with 3 x 3 different Objects (here named item), so a total of 9 objects, already sorted by the price. Each Object is wrapped in another Object (TradingItem). The object property &quot;Tag&quot; of each TradingItem is a so-called placeholder for each item object.
  This is a simple code fragment for demonstrating purposes (how this list were made):</p>
  <pre><code>foreach (var item in market.Inventory.Where(i =&gt; i.Price.HasValue).OrderBy(i =&gt; i.Price))
      list.Items.Add(new TradingItem()
      {
          Tag = item,
          Text = item.Name,
          Value = item.Price.Value
      });
  </code></pre>
  <p>So what I need is to create a new list with only 3 TradingItem Objects, each with a first found item object inside it, and keep the order. Take the first Type of an item object, ignore the next following objects from the same type, then add the next new type to the list, and so on...
  I know how to do it with a simple for each cycle and I found out how to extract the objects separately with LINQ.</p>
  <p>Here an example:</p>
  <pre><code>var books = list.Items.Where(t =&gt; t.Tag is Book).FirstOrDefault();
  var glasses = list.Items.Where(t =&gt; t.Tag is Glass).FirstOrDefault();
  var shoes = list.Items.Where(t =&gt; t.Tag is Shoe).FirstOrDefault();
  </code></pre>
  <p>But these solutions are not really satisfactory. And I need a generic solution without hard code the types like Book, Glass or Shoe. Just a simple list with every three different object types. Does anyone have an idea how to make it clean and simple with LINQ?</p>