I have 2 array:
var arr1 = [1, 1, 2, 3, 4, 4];
var arr2 = [];
arr1 defines some groups, the group members are defined by the position.  So the group members 0 and 1 belong to group 1,
member 2 belong to group 2,
member 3 belong to group 3,
the group member 4 and 5 belong to group 4.
I would like to load the groups with their members into another array, so that I looks like:
arr2 = [[0,1], [2], [3], [4,5]];
So group 1 has the members 0 and 1 and so on...
When doing:
for(i=0; i<arr1.length; i++){
    arr2[arr1[i]] = i;
}
I get:
arr2 = [1: 1, 2: 2, 3: 3, 4: 5];
 
     
     
    