z-sorting

How do I Z-sort triangles for a 3D engine?

I'm building a small 3D engine for a game I'm working on. I've got my basics sorted: textured triangles with backface culling. However depth sorting is proving to be a difficult problem. I'm calculating the face Z by averaging out the 3 points that make up the triangular face. The longer faces sometimes overlap the smaller faces since ...