This information is not accessible, since attributes are stored in a dict, which is inherently unordered. Python does not store this information about order anywhere.
If you want your serialization format to store things in a certain order you would specify that order explicitly. You would not use dir, which contains things you don't know or care about, you would explicitly provide a list (or whatever) describing what to serialize.