Speed always being an issue with flash based 3d (fingers crossed this will change), sorting triangles is something one wants to be able to do as fast as possible.
If your working with vectors you might have noticed that they are slower to sort objects on a property than an array is.
There a numerous articles on the web about different methods to squeeze more speed out but here is what I do (specific to 3d shizznit).
var visibleTriangles:Array = ; /* ...fill array with visible triangles... */ visibleTriangles.sortOn("distanceFromCamera", Array.NUMERIC); return Vector.<Triangle3D>(visibleTriangles);
and that’s it 🙂
Pretty sure this won’t work for everybody but it’s much faster in my tests that using a vector during the sort process. (couldn’t detect any real overhead for the conversion)