Last active
November 3, 2016 23:21
-
-
Save mhseiden/dd76db05c94298b225a7a05789541cc9 to your computer and use it in GitHub Desktop.
O(n) sorting of whole numbers with setTimeout
This file contains 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
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