Depth sorting for entities