Skip to content
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

Case insensitive sort_keys #2194

Open
DAVe3283 opened this issue Nov 13, 2024 · 2 comments
Open

Case insensitive sort_keys #2194

DAVe3283 opened this issue Nov 13, 2024 · 2 comments

Comments

@DAVe3283
Copy link

Please describe your feature request.
Ability to sort keys ignoring case (not case sensitive).

Describe the solution you'd like
If we have data1.yml like:

Foo: 3
apple: 1
bar: 2

And we run a command:

yq -P 'sort_keys_insensitive(..)' data1.yml

it could output

apple: 1
bar: 2
Foo: 3

Describe alternatives you've considered
I tried to use 'sort_keys(..|downcase)' but it does not work (probably as expected).

Additional context
While I don't want to consider case for the purpose of the sort, I would like to retain the case of the keys in the output.

@mikefarah
Copy link
Owner

Will accept a PR for this, this should be done by adding a sort_keys_by function (just as there is a sort_by function here)

You will then be able to: sort_keys_by(downcase)

@mikefarah
Copy link
Owner

Otherwise I may get to it in a few weeks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants