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

How to do sorting for json array #6

Open
roshan-ship-it opened this issue Feb 26, 2016 · 0 comments
Open

How to do sorting for json array #6

roshan-ship-it opened this issue Feb 26, 2016 · 0 comments

Comments

@roshan-ship-it
Copy link

hi,
I have one small example:
var jsonObj = [{
"age": 30,
"name": "James Martin"
},
{
"age": 44,
"name": "ABC",
}
]

var family = jsonQ(JSON.stringify(jsonObj)),
pnames = family.find('name');

result ==> i am getting same result asc or desc sorting..this is happening only if i have Json array...Could you please suggest how to approach this kind of problem..Basically i have requirement where i need to do sorting based on column in json array..
pnames.sort("name",{order:'ASC'}).value()
["James Martin", "ABC"]
pnames.sort("name",{order:'DESC'}).value()
["James Martin", "ABC"]

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

1 participant