Skip to content

Commit

Permalink
Merge pull request TheRenegadeCoder#1989 from aymaneMx/master
Browse files Browse the repository at this point in the history
Added Sleep sort in Python
  • Loading branch information
jrg94 authored Oct 2, 2020
2 parents 2994ed9 + cda13cb commit c9b58de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions archive/p/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Welcome to Sample Programs in Python!
- [ROT-13 in Python][38]
- [Selection Sort in Python][39]
- [Convex Hull in Python][44]
- [Sleep sort in Python][https://github.com/TheRenegadeCoder/sample-programs/issues/1988]

## Fun Facts

Expand Down
20 changes: 20 additions & 0 deletions archive/p/python/sleep_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
import _thread
from time import sleep


def arg_to_list(string):
return [int(x.strip(" "), 10) for x in string.split(',')]


array = arg_to_list(sys.argv[1])


def sleep_sort(i):
sleep(i)
print(i)


for i in array:
arg_tuple = (i,)
_thread.start_new_thread(sleep_sort, arg_tuple)

0 comments on commit c9b58de

Please sign in to comment.