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 Entire Array rather than just the found parameter #12

Open
Cleanshooter opened this issue Dec 6, 2016 · 2 comments
Open

Sort Entire Array rather than just the found parameter #12

Cleanshooter opened this issue Dec 6, 2016 · 2 comments

Comments

@Cleanshooter
Copy link

Rather than having the sort method return only the value of the provided key it would be more useful if there were an option to return the entire JSON object with all data still intact sorted based on the key/parameter identified. Returning an array of sorted values isn't that helpful when it comes to a sort command for most query languages.

@s-yadav
Copy link
Owner

s-yadav commented Dec 6, 2016

Actually, sortMethod do inplace sorting so you can do just

var family = jsonQ(jsonObj);
family.sort('name');

So here now family jsonQ is a sorted object.

Right now .sort method returns a jsonQ object which is simialiar to (family.find('name')), but sorted. So if you do

var family = jsonQ(jsonObj);
var names = family.sort('name');

you will get the names

But yes, I agree it should return the family jsonQ object instead of names. Will check for the impact and will make this change.

@jomy-joseph
Copy link

Is this available now?

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