Skip to content

Instantly share code, notes, and snippets.

@0x-r4bbit
Created February 5, 2016 08:35
Show Gist options
  • Save 0x-r4bbit/fc3a10c4cb8b9f150306 to your computer and use it in GitHub Desktop.
Save 0x-r4bbit/fc3a10c4cb8b9f150306 to your computer and use it in GitHub Desktop.
var sortedByVoteCount;
var oReq = new XMLHttpRequest();
function reqListener () {
sortedByVoteCount = JSON.parse(JSON.stringify(oReq.response))
.posts.sort(function (a, b) {
if(a.vote_count < b.vote_count) return -1;
if(a.vote_count > b.vote_count) return 1;
return 0;
});
}
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://hafven.zendesk.com/api/v2/community/topics/200364775/posts.json");
oReq.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment