title: Merge many short sorted lists into a long sorted list efficiently
body: <p>I'm repeatedly merging 10000 sorted lists into a single long sorted list. Each list contains about 5000 <code>doubles</code>.</p>
  
  <pre><code>double[] result;// this is the single long sorted list
  void merge(double[] x){
      double[] newList=new double[x.length+result.length];
      int i=0,j=0;
      while(i&lt;x.length &amp;&amp; j&lt;result.length){
          insert the smaller one
          increment i or j;
      }
      if(i&lt;x.length){
          add the rest
      }
      if(j&lt;result.length){
          add the rest
      }
      result=newList;
  }
  </code></pre>
  
  <p>This method allocates a new array every time. As <code>result[]</code> grows, this is not efficient. Any advise?</p>