title: What is the best C# Data Structure(s) For the Following Situation
body: <p>The requirements for my application are as follows. I need to store orders which look like this:</p>
  
  <ul>
  <li><p>Each order pertains to a specific stockcode(string) and has a price, volume and whether or not it is being bought or sold(boolean) associated with it.</p></li>
  <li><p>I need to do several operations on all orders that pertain to a specific stock, for example get the sum of the volume of orders for stockcode "abc".</p></li>
  <li><p>I need to be able to add an order to the data structure</p></li>
  <li><p>I need to be able to remove an order from the data structure</p></li>
  <li><p>I need to be able to find out which order is offering the best price after an order is added or removed.</p></li>
  </ul>
  
  <p>Here is what I am thinking so far:</p>
  
  <pre><code>public class Order : IComparable
  {
  
     private string _StockCode;
     private bool _BidSide;
     private int _Volume;
     private decimal _Price;
     private int _ExchangeOrderId;
  
     public int CompareTo(Order other)
     {
          if (_BidSide != other.BidSide)
          {
              return _BidSide ? 1 : -1;
          }
          return decimal.Compare(_Price, other.Price);
     }
  }
  </code></pre>
  
  <p>And then I would store the orders in a  Dictionary&lt;string, List&lt;Order&gt;&gt;. Where each stock code would be a key in the dictionary pointing to a list of orders for that stock.   I would also maintain Dictionary matching an order id to a stock code.</p>
  
  <ul>
  <li><p>For adding a new order, I simply find the appropriate list of orders in the dictionary based on the current stock code, and insert the order. I would also add an entry in the orderstock dictionary matching the current order with the approrpriate list.</p></li>
  <li><p>For finding the best price, I look up the order list in the dictionary for the current stock code, sort the list and print out the highest order.</p></li>
  <li><p>Removing is tricky. I would first need to look up the appropriate list by stock code. I would then need to iterate through all the orders for that stock code and find the one that matches the current order id and remove it. This is obviously inefficient if there are a lot of orders for the current stock code. Is this the best way of storing this information?</p></li>
  </ul>