Skip to content

Instantly share code, notes, and snippets.

@armorasha
Forked from maxcountryman/sleep_sort.py
Last active March 5, 2023 12:24
Show Gist options
  • Save armorasha/47c7236cdfe25a928080692324d7f035 to your computer and use it in GitHub Desktop.
Save armorasha/47c7236cdfe25a928080692324d7f035 to your computer and use it in GitHub Desktop.
Sleep sort in Python 3.8 multi-threading.
# used Python 3.8
import _thread
from time import sleep
items = [2, 4, 5, 2.5, 1, 7]
def sleep_sort(i):
sleep(i)
print(i)
for i in items:
arg_tuple = (i,)
# _thread.start_new_thread(function, args[, kwargs])
_thread.start_new_thread(sleep_sort, arg_tuple)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment