# Sorting array with multiple fields

**URL:** <https://forum.kirupa.com/t/sorting-array-with-multiple-fields/65387>\
**Category:** Uncategorized\
**Created:** [September 25, 2004, 8:25pm UTC](https://forum.kirupa.com/t/sorting-array-with-multiple-fields/65387 "2004-09-25T20:25:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flashmatazz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/flashmatazz/32/140_2.png) [@Flashmatazz](https://forum.kirupa.com/u/Flashmatazz)\
**Post date:** [September 25, 2004, 8:25pm UTC](https://forum.kirupa.com/t/sorting-array-with-multiple-fields/65387/1 "2004-09-25T20:25:49Z")

</div>

Heya,

a quick question: I have an array that gets filled with values from a database and I want to sort things in Flash using the sortOn() function. I’m trying to create an array with a number of fields, like this example from the Help-files:

```auto

var my_array:Array = new Array();
my_array.push({password: "Bob", age:29});
my_array.push({password: "abcd", age:3});
my_array.push({password: "barb", age:35});
my_array.push({password: "catchy", age:4});

```

However, I need a bit more fields and if I put all of these in one line, it gets kinda lengthy.  
I tried something like

```auto

var my_array:Array = new Array();
for (i=0; i<10; i++) {
	my_array.push ( {prop1: "value_1_"+i} );
	my_array.push ( {prop2: "value_2_"+i} );
}

```

but this apparently doesn’t work. Is there another way of doing this?

Cheers.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 25, 2004, 8:36pm UTC](https://forum.kirupa.com/t/sorting-array-with-multiple-fields/65387/2 "2004-09-25T20:36:06Z")

</div>

whoops, I was a bit to quick to post my question. already got it sorted out so it doesn’t get too messy. I just assign within the loop each nodename/attribute from the XML object containing my data to a variable first and at the end push all these values into the fields of the array. so still in one line, but not so messy as I feared 😃
