Anonymous user
Sorting algorithms/Sleep sort: Difference between revisions
Python with async/await
(Python with async/await) |
|||
Line 1,383:
;Sample output:
<pre>sleep sort worked for: [3, 2, 4, 7, 3, 6, 9, 1]</pre>
Since the introduction of async/await syntax, the implementation
could be a sole translation from the original version in Bash:
{{Works with|Python 3.5+}}
<lang python>#!/usr/bin/env python3
from asyncio import run, sleep, wait
from sys import argv
async def f(n):
await sleep(n)
print(n)
if __name__ == '__main__': run(wait(list(map(f, map(int, argv[1:])))))</lang>
Example usage:
<pre>
$ ./sleepsort.py 5 3 6 3 6 3 1 4 7
1
3
3
3
4
5
6
6
7
</pre>
=={{header|Racket}}==
|