Last active
December 5, 2017 21:33
-
-
Save cuuupid/1233509f62ba6266b4c116fbc4b76fa5 to your computer and use it in GitHub Desktop.
SleepSort is a new sorting algorithm that sorts by time.
This file contains hidden or 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 time import sleep | |
from math import log | |
from multiprocessing.dummy import Pool | |
nums = [float(x) for x in input('Positive numbers to sort, delimited by space: ').split(' ')] | |
def sleepsort(x): sleep(log(x)); print(x, end=' ') # O(log(n)) :) | |
pool=Pool(10) | |
pool.map(sleepsort, nums) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Warning, may take long time with large input.
Based on this reddit joke.