It works differently in 2D wireframe and 3D render modes.
In 3D modes, the rendering order depends on the position of the two entities (which one is closer to the camera). If the entities are in the same plane, the result is unpredictable. In 2D wireframe, the render mode depends on the drawing order. By default, the entity that appears first in the file is rendered first.
But this order can be changed using OdDbSortentsTable methods.
The sort table is returned by the OdDbBlockTableRecord::getSortentsTable() method (it makes sense for layout blocks).