I have already get the json data from the link and let it become a table, but now I wanna sort it by name, type, weight, birthday. How can I do that? Is there any existing resource I can use?
<div id="id01"></div>
<script>
$.ajax({
url: "https://tasks.inlogik.com/devtest/animals",
dataType: 'jsonp',
data: '',
jsonp: 'callback',
success: function (arr) {
var out = "<table>";
out += "<tr><td>"+"Name"+"</td><td>"+"Type"+"</td><td>"+"Weight"+"</td><td>"+"Birthday"+"</td><td>"+"Horns?"+"</td><td>"+"Action";
for (var i in arr) {
out += "<tr><td>" +
arr[i].name +
"</td><td>" +
arr[i].type +
"</td><td>" +
arr[i].weight +
"</td><td>" +
arr[i].birthday+
"</td><td>" +
arr[i].hasHorns +
"</td><td>" +
"Details" +
"</td><tr>";
}
out += "</table>";
document.getElementById("id01").innerHTML = out;
},
error: function (jqXHR, textStatus, ex) {
alert(textStatus + "," + ex + "," + jqXHR.responseText);
}
});
</script>