It was being incorrectly assumed that polygons should always be in the same order as loops.
Exporting such a mesh would raise an error during the export or rarely export geometry layers assigned to the wrong polygons.
Polygons and per-polygon data are now sorted into the same order as loops.
In most cases, polygons will already be in the same order as loops, so this will only add about 0.6ms per 1M polygons exported to the export duration due to a single order check per mesh. With many smaller individual meshes this increases, due to overhead per mesh, up to about 6ms per 1M polygons when each mesh has only 1000 polygons.
In the case where the polygons of a mesh need to be sorted, the main cost is an upfront sorting cost:
For polygons almost already in order, this is about 0.05ms to 0.6ms to 35ms for 100_000, 1M and 10M polygons respectively.
For polygons in random order, this is about 6ms to 85ms to 1300ms for 100_000, 1M and 10M polygons respectively.
There is an additional cost per per-polygon data array to be sorted in the same way, which is about 1ms per 1M polygons per number of arrays to be sorted. There is currently a maximum of two such arrays to be sorted per mesh.