title: Best algorithm to group data by similarity (same ID)
body: <p>here is reference code:</p>
  
  <pre><code>struct MyData
  {
  int ID;
  
  // other members
  };
  
  std::vector&lt;MyData&gt; inputData;
  
  std::vector&lt;std::vector&lt;MyData&gt; &gt; outputData = GroupByIDs(inputData);
  </code></pre>
  
  <p>Basically what I want to do is iterate the input data and group the objects by ID into a new mini vector which I would push in the output vector. So in the end I would have a vector of sub-vectors where every sub-vector contains objects with identical <code>ID</code>.</p>
  
  <p>Is there a <em>cookie-cutter most efficient</em> algorithm designed to do this? Because I can only  think of algorithms with a high complexity.</p>