I have 2 arrays which i want to combine (merge), but if value at index 0 from first array is identical with value at index 0 on second array this must be in the same array. More details: Array 1:
var arr1 = [
["SP.22110000295", 1, 162.9],
["SP29372", 1, 1061.6],
["SP3204200014", 5, 1147.5],
["SP324035", 1, 94110.0231]
];
Array 2:
var arr2 [
["999974", 1],
["SP.SAMBACR803805", 1],
["SP29193", 1],
["SP29372", 4],
["SP324035", 3]
]
As you can see (in this example), first array have another 4 array with 3 items, and second 5 array with 2 items. arr1[3][0] (["SP324035", 1, 94110.0231]) is equal with arr2[4][0] (["SP324035", 1])
so i don't know hot achieve a result like this:
var arrfinal = [
["SP.22110000295", 1, 162.9, null], // arr1 index 0 **is not** in arr2 index 0
["SP29372", 1, 1061.6, 4], // arr1 index 0 **is** in arr2 index 0
["SP3204200014", 5, 1147.5, null], // arr1 index 0 **is not** in arr2 index 0
["SP324035", 1, 94110.0231, 3], // arr1 index 0 **is** in arr2 index 0
["999974", null, null, 1], // arr2 index 0 **is not** in arr1 index 0
["SP.SAMBACR803805",null, null, 1], // arr2 index 0 **is not** in arr1 index 0
["SP29193", null, null, 1] // arr2 index 0 **is not** in arr1 index 0
];
Actualy it's not realy a merge, because just arrays where values of index 0 are equals are merged others it's kind of splice.
I tried with merge, expand splice... underscore, jquery...
Any hints please?
Thank you, very much, Geo