AS3: Advanced Depth-Sorting (Help Please)

Hi there. I’m kinda new here so please excuse me.

I need some advice on this

I made a simple isometric board, with dynamic placing of entities. Works fine with 1x1 objects (ie chairs) thanks to Senocular’s AS3 tip.

But now I’m trying to make it depth sort any size objects (2x2,1x2, 1x3 - 3 is the max dimension) but i have absolutely no idea.

            
if (tiles.valid){
                var temp:entity = new entity(sel_furni.path, sel_furni.desc, sel_furni.frame);
                furn_layer.addChild(temp);
                SetObject(temp, evt.target.vx, evt.target.vy);
                
                temp.xPos = evt.target.vx;
                temp.yPos = evt.target.vy;
                placed_furn.push(temp);
                placed_furn.sortOn(["yPos", "xPos"], [Array.NUMERIC| Array.DESCENDING,Array.NUMERIC]);
                
                //Thank you Senocular
                var i:uint = placed_furn.length;
                while(i--){
                    if (furn_layer.getChildAt(i) != placed_furn*) {
                        furn_layer.setChildIndex(placed_furn*, i);
                    }
                }
                //Disable the zone
                var active:Array = tiles.getActive()
                for (i in active)
                {
                    active*.isOpen = false;
                    active*.activate();
                }
            }

the above code works for all cases except 1. Note that I’m not sorting by y property, rather, sorting by xpos,ypos grid coodinates. Since not all the sprites are the same height, sorting with y would be inaccurate.

The above sorts Y descending, followed by X ascending. This works for all, except for the following case:

an entity of height 2, would cause it to overlap an adjacent entity, as one of its “occupied space” would not be taken into account? trouble abounds.

Been racking my head all day for a solution, but no luck yet. Its 2am so i better konk off. Hope to hear some replies when i wake up. Sorry if my post is confusing

Thanks in advanced for any replies.