Re:Sleep Sort
by r00fus on Wednesday June 15, 2011 @02:52PM
(#2658510)
problem with 4chan is that it's blocked at work (probably for good reason). Now I need to find the reddit summary.
[ Parent
| on HN ]
Re:Sleep Sort
by Stormbringer on Wednesday June 15, 2011 @10:41PM
(#2659922)
Sleepsort: For each item in a list of items, create a thread that sleeps as long as its number, then prints its number.
E.g. 5,3,2,1,10 makes five threads, one sleeps for one second and prints 1, one sleeps for two seconds and prints 2, one sleeps for three seconds and prints 3, one sleeps for five seconds and prints 5 and the last one sleeps for 10 seconds and prints 10.