How to sort back parallel (HDF5) dof list to global (serial) mesh order

I’m trying to use HDF5 output from FEniCS parallel runs and am trying to figure out how the solution values/degrees of freedom are sorted (with respect to the mesh). My test example is a basic Poisson equation on a 1D line with 5 cells and linear elements, this results in

cells       = [0 1 2 3 4 5]
cell_dofs   = [1 0 0 5 5 4 4 3 3 2]
vector_0    = [0.08 0 0 0.08 0.12 0.12]
x_cell_dofs = [0    2 4 6    8    10  ]

I had thought “x_cell_dofs” maps the values in “vector_0” to “cell_dofs”, but “cell_dofs” only has 10 entries. I just can’t seem to figure out the ordering. Maybe I’m doing this wrong or there is some utility function, otherwise how can I sort back vector_0 to correspond to the global (serial) dofs/mesh?

Please supply the code that you have used to obtain the HDF5 output for this example.

To me, it looks like x_cell_dofs is the offset for the dofs in each cells, i.e.
dofs_in_cell [i] =cell_dofs[x_cell_dofs[i]:x_cell_dofs[i+1]]