0

I have something that looks like

aInt[0] = {pk:'1', other:'this', otherother:'that'};
aInt[1] = {pk:'1', other:'this2', otherother:'that2'};
aInt[2] = {pk:'2', other:'thisA', otherother:'thatA'};
aInt[3] = {pk:'3', other:'thisB', otherother:'thatB'};

and I want to turn it into

aNew[0] = [1 [{other:'this', otherother:'that'},
              {other:'this2', otherother:'that2'}];
aNew[1] = [2 [{other:'thisA', otherother:'thatA'}];
aNew[2] = [3 [{other:'thisB', otherother:'thatB'}];

or something to that effect. perhaps the syntax on the result is incorrect but I hope my intent is clear. Feel free to edit the syntax. I want to correlate the result set based on values of the pk field in the array of objects I have. in as3

Thanks in advance.

4

1 回答 1

1
for each (var obj:Object in aInt) {
    if (aNew[obj.pk] == undefined)
        aNew[obj.pk] = [];
    aNew[obj.pk].push(obj);
}
于 2013-09-12T15:32:47.173 回答