Created
October 23, 2013 23:59
-
-
Save AyatoKinkori/7128954 to your computer and use it in GitHub Desktop.
手習いsleepsort ref: http://qiita.com/ayahito2828/items/b4346d062ec2c275e4bc
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
import threading | |
import time | |
sort_list = [1, 3, 6, 8, 10, 33, 44, 23] | |
def sort(lis): | |
answer_list = [] | |
for num in lis: | |
thread = threading.Thread(target=sleep, args=(num, answer_list)) | |
thread.start() | |
while (threading.active_count() > 1): | |
time.sleep(0.1) | |
print answer_list | |
def sleep(num, lis): | |
time.sleep(num * 0.1) | |
lis.append(num) | |
if __name__ == "__main__": | |
sort(sort_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment