Dynamic Z Depth Sorting

Does anyone know a quick way of sorting objects depths based on a variable (z depth). I’ve tried a few things but they seem quite slow -

one method involved pushing each object onto an array and then sorting it each frame using a sort function and then using swapDepths to reorder everything on screen. The swapDepths is quick but I think the array sorting is slow. I could possibly write a quicker sort based on shear or merge sorting - are the default actionscript sorts slow?

Does anyone know if it’s any quicker in AS3.0 either?

I could probably work it out given a while, but I thought I’d ask if anyones already done it! :stuck_out_tongue:

Cheers!