If you break the problem down into pieces, you’ll see it’s not so daunting.
Here’s some pseudo-code on how you may want to start approaching the problem:
for each child of the current object (hint: numChildren)
add the child to an array (hint: getChildAt)
sort the objects in the array based on their "y" property (hint: read up on sorting methods)
(alternate hint: check the manual page NineFiveThree posted and look up Array's built-in sort method)
for each object in the array
set the index of the object to its new array position (hint: setChildIndex)
Those 3 steps should be nothing scary individually, and the overarching problem will just be a simple matter of connecting it all together.
|