# Help with array sorting

**URL:** <https://forum.kirupa.com/t/help-with-array-sorting/319338>\
**Category:** flash\
**Created:** [February 16, 2011, 11:00pm UTC](https://forum.kirupa.com/t/help-with-array-sorting/319338 "2011-02-16T23:00:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kill\_robot\_kill](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kill_robot_kill/32/359_2.png) [@kill\_robot\_kill](https://forum.kirupa.com/u/kill_robot_kill)\
**Post date:** [February 16, 2011, 11:00pm UTC](https://forum.kirupa.com/t/help-with-array-sorting/319338/1 "2011-02-16T23:00:43Z")

</div>

I am creating a brainstorming program (see attachment). A user starts with a main idea (middle dot) and can add new ideas and then sub-ideas to the chart. The user often will add them in no particular order, but when they are done I need to have a list that looks like this:  
Main idea  
+Idea  
—Sub Idea  
===Sub Sub Idea  
—Sub Idea  
+Idea  
+Idea  
–Sub Idea

I currently have an array that has two keys ‘ID’ and ‘parent’.  
I am confused as to how I can sort this array so that it traces similar to my above formatting.

using sortOn(parent) disregards the children, so I’m thinking I need to add some sort of check but I’m lost.
