Open simonpercivall opened 7 years ago
We can use dump order strategies for this. e.g.
toml.dumps(data, nested_order=toml.NESTED_FIRST) # As suggested in this PR.
toml.dumps(data, nested_order=toml.NESTED_LAST) # Default/current strategy
The v1.0.0 rc has a preferred ordering:
https://toml.io/en/v1.0.0-rc.3#table
Defining tables out-of-order is discouraged.
# VALID BUT DISCOURAGED [fruit.apple] [animal] [fruit.orange]
# RECOMMENDED [fruit.apple] [fruit.orange] [animal]
I support the approach in #275.
Though not a requirement of the spec, it would be a very nice feature of this library to, when encoding nested dictionaries, write nested tables directly below their parent table, instead of first all top-level sections then the next level, then the next.