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

Sort arrays of objects with the same keys, optionally, additional by value #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hwdegroot
Copy link

When a property value is an array of objects with identical keys,
optionally sort the objects by the value of the keys. This can be
particularly interesting for autogenerated files that are updated by an
external application. i.e. in amplify the configuration files are
serverside updated. Diffing of these files is really hard when the order
changes. A lot of thes files contain arrays of objects with identical
keys. Sorting them by value will always keep them in the same order.

--secondary-sort-by-value, -sv
Sort arrays of objects with identical keys by their value as well.

[
    {
        "b":"c",
        "a": "b",
        "g": "h"
    },
    {
        "b":"c",
        "a": "a",
        "g": "h"
    },
] -> [
    {
        "a": "a",
        "b":"c",
        "g": "h"
    },
    {
        "a": "b",
        "b":"c",
        "g": "h"
    },
]

When a property value is an array of objects with identical keys,
optionally sort the objects by the value of the keys. This can be
particularly interesting for autogenerated files that are updated by an
external application. i.e. in amplify the configuration files are
serverside updated. Diffing of these files is really hard when the order
changes. A lot of thes files contain arrays of objects with identical
keys. Sorting them by value will always keep them in the same order.
@hwdegroot hwdegroot force-pushed the feature-add-secondary-sort-by-value branch from 897cd00 to 12c2b87 Compare February 24, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant