first post here! I currently have my JSON file to display exactly how I want it to via html in a table. However, I am completely lost in terms of how to make this table to be sorted from the point I am at. I have been at this for 2 days now, watching videos and browsing the web, and thought I just need to ask for help. Here's what I have so far...
Sorry: To Clarify, I want to be able to click each table header, and it sorts by that specific column :)
THANKS SO MUCH FOR YOUR TIME!
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<body class="col-md-12">
<div id="displayJSON">
<p>Click Below to load zip.json!</p>
</div>
<a href="#getdata" class="btn btn-primary" id="btnGet">Display Data</a>
<script src="jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function () {
$('#btnGet').click(function () {
var displayResources = $('#displayJSON');
displayResources.text('Loading data from the given zip.json');
$.ajax({type: "GET", url: "zip.json", success: function(result){
console.log(result);
var output="<table><thead><tr><th>City</th><th>Population</th><th>State</th><th>Zip</th></thead><tbody>";
for (var i in result){
output+="<tr><td>" + result[i].city + "</td><td>" + result[i].pop + "</td><td>" + result[i].state + "</td><td>" + result[i]._id + "</td></tr>";
}
output+="</tbody></table>";
displayResources.html(output);
$("table").addClass("table");
}});
});
});
</script>