Skip to content

Instantly share code, notes, and snippets.

@yuyoyuppe
Created September 24, 2019 14:11
Show Gist options
  • Save yuyoyuppe/3dfa4901571fbfb3ac6625340cded58e to your computer and use it in GitHub Desktop.
Save yuyoyuppe/3dfa4901571fbfb3ac6625340cded58e to your computer and use it in GitHub Desktop.
async function sleep_sort(a)
{
let sorted = [];
await Promise.all(a.map(async e => {
await new Promise(resolve => setTimeout(resolve, e));
sorted.push(e);
}));
return sorted;
}
const arrrrr = [5,3,1,10,7,2];
console.log(await sleep_sort(arrrrr));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment