1 // sleepsort.js - Sort integers from the commandline in a very ridiculous way: leveraging timeouts :P
4 var system = require('system');
6 function sleepSort(array, callback) {
9 for ( i = 0, len = array.length; i < len; ++i ) {
10 setTimeout((function(j){
12 console.log(array[j]);
14 (len === sortedCount) && callback();
20 if ( system.args.length < 2 ) {
21 console.log("Usage: phantomjs sleepsort.js PUT YOUR INTEGERS HERE SEPARATED BY SPACES");
24 sleepSort(system.args.slice(1), function() {