2011-06-17 00:56:06 +04:00
|
|
|
###
|
|
|
|
Sort integers from the command line in a very ridiculous way: leveraging timeouts :P
|
|
|
|
###
|
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require 'system'
|
|
|
|
|
|
|
|
if system.args.length < 2
|
|
|
|
console.log "Usage: phantomjs sleepsort.coffee PUT YOUR INTEGERS HERE SEPARATED BY SPACES"
|
2012-05-16 11:37:26 +04:00
|
|
|
phantom.exit 1
|
2011-06-17 00:56:06 +04:00
|
|
|
else
|
|
|
|
sortedCount = 0
|
2012-01-14 19:13:26 +04:00
|
|
|
args = Array.prototype.slice.call(system.args, 1)
|
|
|
|
for int in args
|
|
|
|
setTimeout (do (int) ->
|
2011-06-17 00:56:06 +04:00
|
|
|
->
|
2012-01-14 19:13:26 +04:00
|
|
|
console.log int
|
2011-06-17 00:56:06 +04:00
|
|
|
++sortedCount
|
2012-01-14 19:13:26 +04:00
|
|
|
phantom.exit() if sortedCount is args.length),
|
2011-06-17 00:56:06 +04:00
|
|
|
int
|
|
|
|
|