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
What I have:
arr1 Map
---- ---
x x, 1
x y, 1
x z, 2
y
y
z
What I want:
newArr
----
x x x y y, 1
z , 2
My 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) & x
ElseIf Instr(x, line(1)) Then
Redim Preserve newArr(i)
newArr(i) = newArr(i) & x
Else
i = i + 1
End If
Next
Next
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?
Aucun commentaire:
Enregistrer un commentaire