richie5um / vscode-sort-json

VSCode Extension to Sort JSON objects
https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json
MIT License
110 stars 19 forks source link

Inconsistent results sorting by alphanum #60

Closed efrenmart closed 2 years ago

efrenmart commented 2 years ago

In this example: { "id": "b", "name": "B", "objs": [ { "id": "c", "name": "C" }, { "id": "a", "name": "A" } ] } is sorted by alphanum. The element with id "c" is before element with id "a". Is this correct? Reverse alphanum is correct: { "objs": [ { "name": "C", "id": "c" }, { "name": "A", "id": "a" } ], "name": "B", "id": "b" }

richie5um commented 2 years ago

Yes, if I've read your msg correctly. The 'objs' item is an array, so the items in it aren't sorted by sort-json (only the properties within the objects within the array (i.e. 'id', and 'name'). The idea of sort-json is purely visual, it shouldn't affect the data of the objects.