I have two arrays, the main includes something like 300 values:
var main = [ 182, 928, 192, 111, 493, 1100, 3 ] ..
The secondary includes 10 values, but each value is an array:
var secondary = [{"id" : 3, "category" : "animals"}, {"id" : 111, "category" : "water"}] ..
My question is how can I sort the secondary array by his id’s according to the values in the main array?
You could use the following code if you structure the second array as mentioned.
The solution uses indexOf which may not be present in all browsers. Mozilla provides an implementation for indexOf here.