title: Iterate through two Arrays VBscript
body: <p>I have two arrays, the first one has similar values, and is in sorted order, the second array is basically a CSV map. I want to some how concatenate the values in my first array, so they are all grouped together, based on the second value of the Map</p>
  
  <p>What I have:</p>
  
  <pre><code>arr1                            Map
  ----                            ---
   x                              x, 1
   x                              y, 1
   x                              z, 2
   y
   y
   z    
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>    newArr                            
      ----                            
   x x x y y, 1                                                         
   z , 2  
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>For Each x in arr1
      For each y in Map
          line = Split(y, ",")
          If Instr(x, line(0)) Then
              Redim Preserve newArr(i)
              newArr(i) = newArr(i) &amp; x
          ElseIf Instr(x, line(1)) Then
              Redim Preserve newArr(i)
              newArr(i) = newArr(i) &amp; x
          Else
              i = i + 1
          End If
      Next
  Next
  </code></pre>
  
  <p>My logic was to compare the val in arr1 to map(0), if there were similarities, put it in an array, if there aren't, check map(1), if there is a match there, append it to that value in newArr(i). Only iterate if there are no matches. Obviously my code is not doing that. Thoughts?</p>