Exporting geometry and uv's

I have written a script to export faces (indices), vertices and uv coordinates in a way like so:

face1(vertIndex1, vertIndex2, vertIndex3);
face2(vertIndex1, vertIndex2, vertIndex3);
and so on…

vertex1(x, y, z, U, V);
vertex2(x, y, z, U, V);
and so on…

this specific syntax is required by a 3D engine I am using. I have managed to get everything as I required BUT I have a problem with indices. When I export Mesh Face Indexes it all works fine but it is useless when for the use with UV’s. So I am exporting Map Face Indexes it does export them in exactly same order like when exporting to Collada DAE file format.

Mesh Faces     Map Faces      Map Faces in correct order should be
2, 1, 4                 3, 1, 5               1, 2, 5
3, 2, 4                 4, 3, 5               2, 3, 5
1, 3, 4                 1, 2, 5               4, 1, 5