Skip to content

Can't sort. Sorting cannot produce a determinable result. #27

Closed
@AceTheWiz

Description

@AceTheWiz

I have a string property named "name". When I choose it to sort I get an error. "Sorting cannot produce a determinable result. Please pick another property"

VSC Version: 1.90.1 (user setup)
Commit: 611f9bfce64f25108829dd295f54a6894e87339d
Date: 2024-06-11T21:01:24.262Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.19045

Any ideas.?

Activity

fvclaus

fvclaus commented on Jun 17, 2024

@fvclaus
Owner

This message occurs when the property has one or more non unique values. It should ask you to pick another property, like so:

image

AceTheWiz

AceTheWiz commented on Jun 21, 2024

@AceTheWiz
Author

Thanks for the reply.

I did see the dropdown to choose another property, but I specifically want to sort on the name property.

And yes, the name property does have duplicates but I was hoping it would sort regardless.

Is there a possibility to override or configure the requirement for unique values ?

fvclaus

fvclaus commented on Jun 21, 2024

@fvclaus
Owner

Is there any reason you don't want to pick another property to sort the objects with the same value of your first sort property?

fvclaus

fvclaus commented on Jun 21, 2024

@fvclaus
Owner

Of course such a feature could be added (it is currently not supported) and I remember thinking about it. I just never saw a reason to do so.

fvclaus

fvclaus commented on Jun 21, 2024

@fvclaus
Owner

For example, this array:

[
  {
        "name": "Bob",
        "email": "bob43@gmail.com",
        "age": 36
    },
    {
        "name": "Shyam",
        "email": "shyam23@gmail.com",
        "age": 28
    },
    {
        "name": "Bob",
        "email": "bob32@gmail.com",
        "age": 41
    },
    {
        "name": "John",
        "email": "john@gmail.com",
        "age": 33
    },
    {
        "name": "Ram",
        "email": "ram@gmail.com",
        "age": 23
    },
    {
        "name": "Bob",
        "email": "bob43@gmail.com",
        "age": 36
    }
]

has 3 occurrences of Bob. You could either sort by email as the second sort property or by age and email (because 36 appears twice). The Bobs would be sorted among each other by email and among the rest of the objects by name.

AceTheWiz

AceTheWiz commented on Jun 21, 2024

@AceTheWiz
Author

Is there any reason you don't want to pick another property to sort the objects with the same value of your first sort property?

The first prompt I get is this
image
where I chose name.

The second prompt I get is this

I thought that if I chose another property (e.g description), then it would only sort on description and not sort on the name property anymore.

Now, from your explanation and example, I understand that that the "pick another property to sort the objects" actually adds additional fields to the sort. So, the sort then uses multiple fields to sort.

I tried again and kept adding properties to the sort (2nd image above) until it actually sorted successfully as I wanted. 👍

As an improvement, I suggest the text should say "pick an additional property to produce a successful sort"

Thanks again for your time and for creating this useful extension.

reopened this on Feb 1, 2025
fvclaus

fvclaus commented on Feb 3, 2025

@fvclaus
Owner

I tried to improve the message by using a title and including the selected object properties. I hope this is clearer now:

Before After
sort_quickpick01_4 0 0 sort_quickpick01_4 1 0
sort_quickpick02_4 0 0 sort_quickpick02_4 1 0

This is now released as 4.1.0. Feedback is appreciated.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Can't sort. Sorting cannot produce a determinable result. · Issue #27 · fvclaus/vsc-sort-json-array