Vertex order is changed when .obj is loaded - how to fix?

I load an .obj file with 473 vertices and a corresponding number of normals and texture coordinates. The resulting model loads and is displayed correctly however, when I inspected the vertex buffer like this:


let vertexBuffer = mesh.vertexBuffers.first!

let rawVertices = vertexBuffer.buffer.contents().bindMemory(to: Float.self, capacity: vertexBuffer.length / MemoryLayout<Float>.stride)


print("verts: ", rawVertices[0], rawVertices[1], rawVertices[2])


My vertex descriptor formats the data like this:


position x, position y, position z, normal x, normal y, normal z, u, v


where each value is a float so the stride is 8 floats per vertex.


The vertex buffer contained all 473 vertices but the order was not the same as what was in the original .obj file. I expected to see the first vertex with its corresponding normal and texture coordinate but I saw what turned out to be the 4th vertex in the .obj file.


What can I do to stop the model loader from reordering my vertices? I need to keep the vertices in exactly the same order as the .obj file since I perform some mapping operations and the offline data I use is created using the .obj file.


Thanks for any help!