Closed marvfinsy closed 1 year ago
Hi @marvfinsy, interesting problem 🤔 .
I can't remember why the Dumper sorts the keys, probably because in old Ruby versions the Hash didn't have order!
Could you please provide me an example of what you are trying to achieve and expectations? I think there is a simple way to address this issue.
Bad news @marvfinsy, even if I add an option to preserve keys order here, the output will change anyway because the keys are processed in order by type
🤔 I wonder if you can come up with a different structure. Arrays preserve the order.
For more information. i have a UI that allows a customer to save report configuration. part of this is to allow them to filter and order columns. Next want to save the configuration. Was thinking that Toml would be nicer to use than Yaml or Json. Each section of the report has different sections (i.e. root key). Below is the ColumnHeadings section.
ex: [ColumnHeadings] manufactured_by = "my company" model = "model one" year = "year one"
The order of those columns as selected was: "model", "year", "manufactured_by". I'd like the output to be:
[ColumnHeadings] model = "model one" year = "year one" manufactured_by = "my company"
The order of the reporting sections: "Titles", "ColumnHeadings", etc... is not important. I can locate them by root_key. what i'd like to preserve is the order of the columns.
~Marvin
In my situation i am ordering "columns" for a report based on customer request. i am using TOML format to persist this information to a file. I see that ur Dump() sorts the output. In my case this "blows away" the column order requested.
Is there a way to generate this output preserving the original order?
thx ~Marvin Foster