Created
February 5, 2016 08:35
-
-
Save 0x-r4bbit/fc3a10c4cb8b9f150306 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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