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

Why is this not sorting? #40

Closed
k-byun opened this issue Oct 21, 2020 · 6 comments
Closed

Why is this not sorting? #40

k-byun opened this issue Oct 21, 2020 · 6 comments

Comments

@k-byun
Copy link

k-byun commented Oct 21, 2020

[
    {
        "destination": {
            "id": "xx-abc-b-diskuse01"
        }
    },
    {
        "destination": {
            "id": "xx-abc-b-diskalloc01"
        }
    }
]

=> diskalloc01 should appear first but it doesn't.

@k-byun
Copy link
Author

k-byun commented Oct 21, 2020

Ruling out the string length to troubleshoot - this also does not sort:
image
[ { "destination": { "id": "xx-abc-b-diskuse01" } }, { "destination": { "id": "xx-abc-b-diskall01" } } ]

@richie5um
Copy link
Owner

Hi. The extension doesn’t rearrange array positions - instead it only rearranges keys as they has no impact on the meaning of the JSON.

@k-byun
Copy link
Author

k-byun commented Oct 21, 2020

Good to know. I am using notepad++ to compare two JSON files but because the same content is positioned in different positions of within the same array in two different files, it's being detected as difference. Figured sorting both version would align and sort out this so I found your tool to pre-process this in vs code, then pass it to notepad++ - there might be a simpler process which I am not aware of.

I may make a pull request of your add-on extension to implement this later this week/month.
Thank you

@richie5um
Copy link
Owner

Hi. Array sorting is not something this extension is designed for - if you want an array sorting extension then that should be a separate extension :). Array position order has meaning, dictionary key order doesn’t.

For your specific needs, if array position does not have meaning, then it may be easier for you to write a super simple JavaScript script to read in the file, sort the arrays in code, and write out the sorted arrays for comparison.

@richie5um richie5um reopened this Oct 21, 2020
@k-byun
Copy link
Author

k-byun commented Oct 21, 2020

Agreed. That's what I will do. Thanks!

@FlorianWendelborn
Copy link

@richie5um @k-byun I think this can be closed

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

No branches or pull requests

3 participants