Sorting algorithms/Sleep sort: Difference between revisions

→‎{{header|D}}: use parallel instead of fibers
m (added Category:Sorting)
(→‎{{header|D}}: use parallel instead of fibers)
Line 310:
 
=={{header|D}}==
<lang d>void main(string[] args)
import core.thread, std.concurrency, std.datetime,
std.stdio, std.algorithm, std.conv;
 
void main(string[] args)
{
import core.thread, std.concurrency, std.datetime,;
if (!args.length)
args[1..$].map!(a => a.to!uint).parallel.each!((a)
return;
{
 
Thread.sleep(dur!"msecs"(10 * numa));
foreach (number; args[1 .. $].map!(to!uint))
spawnwrite((uinta, num" ") {;
});
Thread.sleep(dur!"msecs"(10 * num));
}</lang>
writef("%d ", num);
}, number);
 
thread_joinAll();
}
 
</lang>
{{out}}
<pre>./sorting_algorithms_sleep_sort 1200 620 250 510 3 480
110 220 350 480 5 6200</pre>
 
=={{header|Dart}}==
Anonymous user