Created
April 25, 2017 17:16
-
-
Save leobetosouza/e06750fa49c4261629b7c6a1261497c6 to your computer and use it in GitHub Desktop.
JS Sleep Sort
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 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