Skip to content

Instantly share code, notes, and snippets.

@cuuupid
Last active December 5, 2017 21:33
Show Gist options
  • Save cuuupid/1233509f62ba6266b4c116fbc4b76fa5 to your computer and use it in GitHub Desktop.
Save cuuupid/1233509f62ba6266b4c116fbc4b76fa5 to your computer and use it in GitHub Desktop.
SleepSort is a new sorting algorithm that sorts by time.
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()
@cuuupid
Copy link
Author

cuuupid commented Dec 5, 2017

Warning, may take long time with large input.

Based on this reddit joke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment