@JavaScriptDaily @joseph_silber let d=t=>new Promise(r=>setTimeout(()=>r(t),t));let s=c=>Promise.all(c.map(d));s([8,42,38,111,2,39,1]).then(console.log)
@JavaScriptDaily This is actually kinda genius. I'm giving respect for originality and comedic timing.
@JavaScriptDaily Not deterministic. Anything <10ms can return in order of calling. Can fix it up with setTimeout(..., num * 1000); Time complx is the same!
@JavaScriptDaily @js_digest Push it to an array and you have a working algorithm :LOL:
@JavaScriptDaily @jonikorpi With a little modification that could work really well as a quick way of scheduling the Web Audio API just ahead of time.
@JavaScriptDaily The complexity should be O(n) as sleeping does increase it. Pretty strong stuff!!
@JavaScriptDaily Check this out . function sorting(arr) { const sortArr = []; arr.forEach((a) => (sortArr[a] = a)); return sortArr.filter((s) => s != null); }