I'm trying to sort the JSON by release date, by random, by alphabetical order or by popularity. I'm not sure if the answer is on here, I checked and I can't seem to figure out if it's for me.
My JavaScript jQuery code grabs the JSON file for me:
$.getJSON("js/example.json", function(data) {
$.each(data.articles, function() {
//code
});
});
I want JavaScript to collect the data from all the items in the articles and sort them. After that, it could probably be added into the HTML through a for() or something better.
Here is what the JSON looks like.
{
"articles":[
{
"name":"aaa",
"date":"10/13/15",
"views":65
},
{
"name":"ccc",
"date":"10/17/15",
"views":175
},
{
"name":"bbb",
"date":"10/11/15",
"views":54
},
{
"name":"ddd",
"date":"10/17/15",
"views":6
}
]
}