title: Insert multiple items into List or Array (no Linq and not quite CodeGolf)
body: <p>No matter how I try, I can't seem to create a nice and clean algorithm for doing the following:</p>
  
  <ol>
  <li>System.Array (or generic List) <em>data</em> of System.Object</li>
  <li>System.Array (or generic List) <em>xval</em> of System.Object</li>
  <li>System.Array (or generic List) <em>idxs</em> of System.Int32</li>
  </ol>
  
  <p><em>xval</em> and <em>idxs</em> contain the same number of elements and <em>idxs</em> contains no values less than zero or larger than <em>data.Length</em></p>
  
  <p>I need to insert all elements in <em>xval</em> into the <em>data</em> array, where the associated integer in <em>idxs</em> represents the insertion index in the original, unmolested <em>data</em>.</p>
  
  <p>For example:</p>
  
  <pre><code>*data* = {A, B, C, D, E, F, G, H}
  *xval* = {U, V, W, X, Y, Z}
  *idxs* = {5, 0, 0, 0, 1, 1}
  
  *output* = {V, W, X, A, Y, Z, B, C, D, E, U, F, G, H}
  </code></pre>
  
  <p>It's easy enough to do, but I always end up with icky code. My best attempt so far (but I'm worried about rounding errors):</p>
  
  <pre><code>  idxs.Reverse()
    xval.Reverse()
  
    Dim N As Int32 = data.Count + xval.Count
    Dim map(N - 1) As Double
    Dim output(N - 1) As Object
  
    Dim k As Int32 = -1
    For i As Int32 = 0 To data.Count - 1
      k += 1
      map(k) = i
      output(k) = data(i)
    Next
    For i As Int32 = 0 To xval.Count - 1
      k += 1
      map(k) = idxs(i) - ((i + 1) * 1e-8)
      output(k) = xval(i)
    Next
  
    Array.Sort(map, output)
  </code></pre>