Created
September 20, 2016 14:43
-
-
Save ohe/70bb02c96e512a109c2ced7599201e4d to your computer and use it in GitHub Desktop.
The only sort algorithm you need
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
from threading import Thread | |
import time | |
a = [3, 1, 4] | |
def sleepsort(array): | |
results = [] | |
threads = [] | |
def runner(x): | |
time.sleep(x) | |
results.append(x) | |
for x in array: | |
t = Thread(target=runner, args=(x,)) | |
t.start() | |
threads.append(t) | |
for t in threads: | |
t.join() | |
return results | |
print sleepsort(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment