I was experimenting with a pie-menu for workspace selection, and realized there is currently no way in Python to access the Workspace.order field which tells me which order the workspaces are placed in the tabs on the top.
I think there are some straightforward ways to do this. I would submit a patch, but I don’t have a current Blender build up.
One method is to simply expose the Workspace.order struct element to Python. This would have the negative consequence of letting python set the number, which is not a good thing to do, but it would be quick and simple. Another option is to might be to make a new Python API to get the workspaces in a properly ordered list.
Here are links to where the Workspace order field is… and where the python RNA is built for this structure.