Friday puzzle

My good friend Frank just sent me this email (I did translate to English though). I had never seen the algorithm before, so it gave me a good laugh. Now I need to share it. It’s written in Groovy:

If you just need to get some blood through the neural cells after the pork roast, try to figure out the code below.

Hint: a classic sort algorithm, but which one?

—————————————–

import java.util.concurrent.*

def list = new CopyOnWriteArrayList()

def task = { n ->
t = {
sleep(n);
list.add(n)
} // job in a closure
t as Callable // return block as a callable }

def workers = []

[5, 3, 7, 2, 1, 1, 3, 4].each { n ->
workers.add(task(n))
}

def executor = Executors.newFixedThreadPool(workers.size());
def futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);

println list # the sorted list


So, what is it? Eh’? Eh’? :o)