Skip to content

tdhopper/sleepsort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I saw this tweet the other day:

Here's a vey strange Sorting Algorithm:

For every element X on the sequence the program does this:
1) Sleeps for X seconds
2) Prints X

The clock starts simultaneously for all elements.

— Fermat's Library (@fermatslibrary) December 4, 2017

And it seemed like a good opportunity to demonstrate asyncio.

./sleepsort.py contains a command line application that can sort positive integers by sleeping. It requires Python 3.7.

If you have poetry, you can run:

poetry run ./sleepsort.py 6 2 8 3 6 9

Run a test (that checks against sorted) with

poetry run pytest

About

Single-threaded Sleep Sort implemented in Python 3.7

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages