# How can I sort an array with objects in?

**URL:** <https://forum.kirupa.com/t/how-can-i-sort-an-array-with-objects-in/123060>\
**Category:** Uncategorized\
**Created:** [September 20, 2004, 2:51am UTC](https://forum.kirupa.com/t/how-can-i-sort-an-array-with-objects-in/123060 "2004-09-20T02:51:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![OM2](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@OM2](https://forum.kirupa.com/u/OM2)\
**Post date:** [September 20, 2004, 2:51am UTC](https://forum.kirupa.com/t/how-can-i-sort-an-array-with-objects-in/123060/1 "2004-09-20T02:51:23Z")

</div>

I want to sort an array that contains object references.  
I want to sort on one of the values held by the objects.

I have the following sample code, say:

```auto

   ActionScript:abc = new Array();
   
   abc[0] = new Object();
   abc[0].anotherObj = new Object();
   abc[0].anotherObj.myNumber = 21;
   
   abc[1] = new Object();
   abc[1].anotherObj = new Object();
   abc[1].anotherObj.myNumber = 11;
   
   abc[2] = new Object();
   abc[2].anotherObj = new Object();
   abc[2].anotherObj.myNumber = 2;
   
   abc[3] = new Object();
   abc[3].anotherObj = new Object();
   abc[3].anotherObj.myNumber = 3;
   
   abc.sortOn("anotherObj.myNumber", Array.NUMERIC);
   trace(abc[0].anotherObj.myNumber);
   trace(abc[1].anotherObj.myNumber);
   

```

In the above code… I want to sort on anotherObj.myNumber.  
The above doesn’t work.  
I wasn’t sure what I should put for anotherObj.myNumber??

Any help would be appreciated.

Thanks.

OM
