jsonQ
jsonQ copied to clipboard
Sort Entire Array rather than just the found parameter
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.
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.
Is this available now?