Skip to content

Allow keypaths to preserve order #404

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

Closed
mucmch opened this issue Apr 30, 2024 · 4 comments
Closed

Allow keypaths to preserve order #404

mucmch opened this issue Apr 30, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@mucmch
Copy link

mucmch commented Apr 30, 2024

Given a benedict dictionary d, invoking d.keypaths() will return all paths in a sorted order.

There are cases where this is an undesired behavior and is caused by kps.sort() in benedict.core.keypaths.py.

I would propose a new parameter "sorted" to keypaths that allows to disable this line of code.

@mucmch mucmch added the enhancement New feature or request label Apr 30, 2024
@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Apr 30, 2024

@mucmch I agree with adding a "sorted" parameter to keypaths method (defaults to True for backward compatibility).

Do you want to submit a PR with a couple tests?

@mucmch
Copy link
Author

mucmch commented Apr 30, 2024

Did a simple implementation, but do not manage to commit to Github. I attached a patch file.

keypaths_order.patch

@kotfu
Copy link
Contributor

kotfu commented Jan 17, 2025

New user of benedict here, and I could benefit from this "sorted" parameter. I'll submit a PR shortly.

@fabiocaccamo
Copy link
Owner

@kotfu thank you very much for the PR!
@mucmch parameter available in 0.34.1.

@github-project-automation github-project-automation bot moved this from Todo to Done in Open Source Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants