Skip to content

Instantly share code, notes, and snippets.

@marcusramberg
Created April 22, 2016 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusramberg/f789306f4f580c6cf1270ca12a333391 to your computer and use it in GitHub Desktop.
Save marcusramberg/f789306f4f580c6cf1270ca12a333391 to your computer and use it in GitHub Desktop.
sub sleep_sort (*@list where .all >= 0) {
my $channel = Channel.new;
await @list.map: -> $delay {
Promise.start({
sleep $delay / 1000;
$channel.send($delay);
});
};
$channel.close;
return $channel.list;
}
say sleep_sort(3,2,1,5,4) for (1 ... 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment