Skip to content

Instantly share code, notes, and snippets.

@leobetosouza
Created April 25, 2017 17:16
Show Gist options
  • Save leobetosouza/e06750fa49c4261629b7c6a1261497c6 to your computer and use it in GitHub Desktop.
Save leobetosouza/e06750fa49c4261629b7c6a1261497c6 to your computer and use it in GitHub Desktop.
JS Sleep Sort
const sleepSort = async arr => {
var res = [];
await Promise.all(arr.map(n => new Promise(resolve => setTimeout(_ => resolve(res.push(n)), n))));
console.log(res);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment