# How to synchronize arrays

**URL:** <https://forum.kirupa.com/t/how-to-synchronize-arrays/228650>\
**Category:** Uncategorized\
**Created:** [June 10, 2007, 2:57am UTC](https://forum.kirupa.com/t/how-to-synchronize-arrays/228650 "2007-06-10T02:57:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasxa](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sasxa](https://forum.kirupa.com/u/sasxa)\
**Post date:** [June 10, 2007, 2:57am UTC](https://forum.kirupa.com/t/how-to-synchronize-arrays/228650/1 "2007-06-10T02:57:04Z")

</div>

i need help on this one, my brain stopped working (:

how to synchronize 2 arrays? let’s say I have squares and circles with numbers, like (c1, c2, c3…) and (s2, s4, s3, s1…). I need to make new array that will sort one array based on other… they don’t have to have same number of items, if that’s the case only things that are in smaller array have to be sync.ed…

i’ve tried this:

```auto

for (var i:int = 0; i < first.length; i++) {
  for (var j:int = 0; j < second.length; j++) {
    if (first*.number != second[j].number) {
      temp.push(second.shift());
      second.push(temp.pop());
    } else {
      newArray.push(second[j]);
    }
  }
}

```

but i have a problem when number of items isn’t same in first and second array…

in my application im loading objects with xml properties. I made 2 arrays, one with display objects- items are added as they load, the other array (with xml properties of each object) is created in loop when i make loaders… So, i don’t know when my object will finish loading and I already have xml array. I have to synchronize them as my objects load, since I want to be able to access properties of even one loaded object…
