Sorting algorithms/Sleep sort: Difference between revisions

Content added Content deleted
(Python with async/await)
(→‎{{header|Python}}: Formatting changes)
Line 1,360: Line 1,360:


=={{header|Python}}==
=={{header|Python}}==
==Python: Using threading.Timer==

<lang python>from time import sleep
<lang python>from time import sleep
from threading import Timer
from threading import Timer
Line 1,383: Line 1,385:
;Sample output:
;Sample output:
<pre>sleep sort worked for: [3, 2, 4, 7, 3, 6, 9, 1]</pre>
<pre>sleep sort worked for: [3, 2, 4, 7, 3, 6, 9, 1]</pre>

===Python v3.5+: Using asyncio ===


Since the introduction of async/await syntax, the implementation
Since the introduction of async/await syntax, the implementation
Line 1,395: Line 1,399:
print(n)
print(n)


if __name__ == '__main__': run(wait(list(map(f, map(int, argv[1:])))))</lang>
if __name__ == '__main__':
run(wait(list(map(f, map(int, argv[1:])))))</lang>
Example usage:
Example usage:
<pre>
<pre>