Skip to content

Instantly share code, notes, and snippets.

@mhseiden
Last active November 3, 2016 23:21
Show Gist options
  • Save mhseiden/dd76db05c94298b225a7a05789541cc9 to your computer and use it in GitHub Desktop.
Save mhseiden/dd76db05c94298b225a7a05789541cc9 to your computer and use it in GitHub Desktop.
O(n) sorting of whole numbers with setTimeout
function sort(i,c) {
var o = [], r = i.length;
i.forEach(function(v) {
setTimeout(function() {
o.push(v);
if(0 === --r) {
c(o);
}
}, v);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment