# Sorting array by id and parent id

**URL:** <https://forum.kirupa.com/t/sorting-array-by-id-and-parent-id/162480>\
**Category:** Uncategorized\
**Created:** [September 13, 2005, 6:43pm UTC](https://forum.kirupa.com/t/sorting-array-by-id-and-parent-id/162480 "2005-09-13T18:43:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipip](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/philipip/32/1231_2.png) [@philipip](https://forum.kirupa.com/u/philipip)\
**Post date:** [September 13, 2005, 6:43pm UTC](https://forum.kirupa.com/t/sorting-array-by-id-and-parent-id/162480/1 "2005-09-13T18:43:46Z")

</div>

hi,

Im building a flash menu/section system for a cms. Im have a  
little problem of sorting a array. The array get its rows from  
a mysql db, im using PHPobject to get the sql records in flash.

MySql table has following colums; id, title, parent-id. When all  
is stored in a flash array it look likes this;

row id, title, pid  
[0] - 34,2005,0  
[1] - 35,Nyheter,34  
[2] - 36,Om Brasswind,34

And here comes my problem, when i attach movieclips i get linare  
menu if you understand, but what i wont is a three-menu look at it,  
like this;

2005 (id 34 pid 0)  
|  
± Nyheter (id 35 pid 34)  
|  
± Om Brasswind (id 36 pid 34)

Is possible to sort array this way? any advices…

her is my code used to get the ‘linare’ kind;

```auto

function viewSectionRecords(){
	for (var i=0; i<sectionRow.length; i++){		
		var item_obj = this.createEmptyMovieClip ("item_holder"+i, i);
		item_obj._x = 120; 
		item_obj._y = 145;
		var holder_obj = item_obj.attachMovie ("section_item_mc", "section_item_mc"+i, i)
		holder_obj._x = 0;
		holder_obj._y = 7 + ((holder_obj._height * i)+3);
		holder_obj.item_txt.text = sectionRow*[1];
	}
}

```
