Comment by nlco
15 years ago
your code can be simplified a bit:
function sleep_sort (inputs) {
function child (number) {
setTimeout(function () {console.log(number)}, Math.pow(2,number))
}
for (var i = 0; i < inputs.length; ++i)
child(inputs[i])
}
sleep_sort(process.argv.slice(2));
That won't work for numbers < -5 and has a much longer worst case.