Created
May 20, 2021 12:28
-
-
Save shuding/5b6a8b79d2b702a8f43599af907f01db 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
const delaySort = (arr) => { | |
const r = [] | |
for (let x of arr) { | |
setTimeout(v => { r.push(v); if (r.length === arr.length) console.log(r) }, x, x) | |
} | |
} | |
// delaySort([3, 2, 1]) => [1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment