You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be able to see the differences quickly regardless of any formatting or ordering of hashes.
It should sort all hashes by the lexical order of their keys; for the entire file, regardless of depth.
This is available via sort_keys(..) as documented in the manpage, but how about the command-line option for ease of use, esp. with other complex expressions.
Describe the solution you'd like
If we have data1.yml like:
(please keep to around 10 lines )
hash:
keyZ: ZambiakeyA: Australia
And we run a command:
yq -P --sort-keys .
it should output
hash:
keyA: AustraliakeyZ: Zambia
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Existing workarounds:
Convert to json, sort in JQ, convert back to YAML. This loses comments, anchors, references.
yq $EXPR file-A | yq -P 'sort_keys(..)' => extra exec, sometimes forget about it
The text was updated successfully, but these errors were encountered:
I tried to use sort_keys but it only sorts one level of keys, and here I am trying to compare .gitlab-ci.yml files, and those have multiple levels of objects.
Please describe your feature request.
TL;DR: Please add a
yq --sort-keys
option, likejq --sort-keys
.jq
has a--sort-keys
option, that sorts the keys in the output consistently.I use it in shell commands like:
To be able to see the differences quickly regardless of any formatting or ordering of hashes.
It should sort all hashes by the lexical order of their keys; for the entire file, regardless of depth.
This is available via
sort_keys(..)
as documented in the manpage, but how about the command-line option for ease of use, esp. with other complex expressions.Describe the solution you'd like
If we have data1.yml like:
(please keep to around 10 lines )
And we run a command:
yq -P --sort-keys .
it should output
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Existing workarounds:
yq $EXPR file-A | yq -P 'sort_keys(..)'
=> extra exec, sometimes forget about itThe text was updated successfully, but these errors were encountered: