Sorting algorithms/Sleep sort: Difference between revisions

Content added Content deleted
(→‎{{header|D}}: use parallel instead of fibers)
Line 313: Line 313:
{
{
import core.thread, std;
import core.thread, std;
args[1..$].map!(a => a.to!uint).parallel.each!((a)
args.drop(1).map!(a => a.to!uint).parallel.each!((a)
{
{
Thread.sleep(dur!"msecs"(a));
Thread.sleep(dur!"msecs"(a));
Line 320: Line 320:
}</lang>
}</lang>
{{out}}
{{out}}
<pre>./sorting_algorithms_sleep_sort 200 20 50 10 80
<pre>$ ./sorting_algorithms_sleep_sort 200 20 50 10 80
10 20 50 80 200</pre>
10 20 50 80 200</pre>