Fespace boundary sort

Dear all,

Can anyone enlighten me on the relationship between the mesh connectivity and the fespace connectivity?
I actually rearranged my mesh nodes on the boundaries to make sure they’re in ascending order with regards to an axis (say Y axis), but the related dofs are not sorted the same way in the fespace. In fact, when I return the dofs on that specific boundary, there is no respected ordering. Actually, I need this to glue submeshes (as in domain decomposition), and I need that the boundary numbering where I glue my meshes follow the same logic.

Thanks.

This is using P2 elements