title: Fastest way to sort and concatenate million or billion STL vectors
body: <p>What is the best way to sort and concatenate million or billion STL vectors into a single STL vector. Presently, the way I am doing it is to just iterate over the vectors and perform each operation.</p>
  
  <p>Here is the pseudo code</p>
  
  <pre><code>typedef unsigned long long int ULLInt;
  
  ULLInt N = 1000000;
  
  vector&lt;vector&lt;ULLInt&gt; &gt; vecVec( N, vector&lt;ULLInt&gt;() );
  vector&lt;ULLInt&gt;          concatVec;
  
  // ...
  // ... fill vectors inside vecVec here 
  // ..  we also get here the total number of values inserted in all vectors (count)
  // ...
  
  // reserve the space
  concatVec.reserve( count);
  
  // sort each vector and concatenate them in sequence
  for( ULLInt i=0; i&lt;N; i++)
    sort( vecVec[i].begin(), vecVec[i].end() );
    concatVec.insert( concatVec.end(), vecVec[i].begin(), vecVec[i].end() );
  end for
  </code></pre>
  
  <p>Note that there is no requirement for concatVec to be sorted. Thanks for suggestions. </p>