# Arranging Elements of an Assoiciative Array

**URL:** <https://forum.kirupa.com/t/arranging-elements-of-an-assoiciative-array/299338>\
**Category:** flash\
**Created:** [November 3, 2009, 3:51pm UTC](https://forum.kirupa.com/t/arranging-elements-of-an-assoiciative-array/299338 "2009-11-03T15:51:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raabi](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Raabi](https://forum.kirupa.com/u/Raabi)\
**Post date:** [November 3, 2009, 3:51pm UTC](https://forum.kirupa.com/t/arranging-elements-of-an-assoiciative-array/299338/1 "2009-11-03T15:51:22Z")

</div>

Hello everybody!

I had been trying to output the result of the following code in a predictable sequence of my choice:

```auto
 
var arrAnimal1: Object = new Object();
var arrAnimal2: Object = new Object();
var arrAnimal3: Object = new Object();
arrAnimal1 = { animal: "Cat", sound: "Meows", pet: "Yes" }; 
arrAnimal2 = { animal: "Dog", sound: "Barks", pet: "Yes" }; 
arrAnimal3 = { animal: "Lion", sound: "Roars", pet: "No" };
 
var arrAnimals: Object = new Object();
arrAnimals = [arrAnimal1, arrAnimal2, arrAnimal3];
for (var keyAnimals in arrAnimals)
{
[INDENT]for (var keyAnimal in arrAnimals[keyAnimals])
{
[INDENT]trace (keyAnimal + ": " + arrAnimals[keyAnimals][keyAnimal]);
[/INDENT]}
[/INDENT][INDENT]trace ("
");
[/INDENT]}

```

The output of the above code appears in a different sequence for every animal, each time.  
pet: Yes  
sound: Meows  
animal: Cat

pet: Yes  
sound: Barks  
animal: Dog

pet: No  
sound: Roars  
animal: Lion

How can get the result, in the following sequence, for example:  
animal: Cat  
sound: Meows  
pet: Yes

animal: Dog  
sound: Barks  
pet: Yes

Looking for the help.
