-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order keys when saving yaml #28
Comments
It sounds reasonable, maybe it should even be the default. |
I have a possible solution for this, which introduces a |
I think sorting by default is reasonable. All perl5 YAML modules do this. |
if |
@Tyil I will implement that for perl5 YAML::PP with Tie::IxHash. Is there something similar in perl 6? |
Any updates? This is still an issue (which I've just stumbled across trying to version control generated yaml output from this module). |
I've just pushed a fix for this. |
If such a module existed this would be easy enough to add (it's already possible to override what it does for mapping the various yaml types to raku types) |
Thanks. That fixes the sorting for the top-level keys, but it isn't working for nested keys (ie: an array of hashes). I tried extending the patch myself, but my naive attempt inadvertently led to it sorting the arrays to :-x FYI, you also need to bump the version number in the META.json so zef will pick up that there's updates to be installed. |
Yeah, that's a bug. Fixed now.
Done that too. |
Perfect. Everything worked as expected now, including 'zef upgrade YAMLish' to get the latest updates. Thanks. |
Ready to close? |
When I use
save-yaml
on a variable, the output differs each time, as the keys are iterated over in a random order. InJSON::Fast
I introduced:sorted-keys
to resolve the issue, but I don't see an easy way to go about it inYAMLish
, so I can't bring in a PR to fix it. Can a similar feature be introduced inYAMLish
?The text was updated successfully, but these errors were encountered: