Created
April 22, 2016 15:06
-
-
Save marcusramberg/f789306f4f580c6cf1270ca12a333391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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