-
-
Save isaacd9/c952f25c15f3a442775c337d35564702 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/local/bin/node | |
const sort = (arr) => { | |
const sorted = []; | |
const sleep = (strNum) => { | |
return new Promise((resolve, reject) => { | |
num = parseInt(strNum); | |
setTimeout((num) => { | |
sorted.push(num); | |
resolve(); | |
}, num, num); | |
}); | |
}; | |
return Promise.all(args.map(sleep)).then(() => Promise.resolve(sorted)); | |
}; | |
args = process.argv; | |
args.shift(); | |
args.shift(); | |
sort(args).then(console.log); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment