Skip to content

Instantly share code, notes, and snippets.

@shuding
Created May 20, 2021 12:28
Show Gist options
  • Save shuding/5b6a8b79d2b702a8f43599af907f01db to your computer and use it in GitHub Desktop.
Save shuding/5b6a8b79d2b702a8f43599af907f01db to your computer and use it in GitHub Desktop.
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