MCPcopy Create free account
hub / github.com/ActiveState/code / sleep_sort

Function sleep_sort

recipes/Python/577756_Sleepsort/recipe-577756.py:9–18  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

7 print(n)
8
9def sleep_sort(s):
10 # Idea inspired by: http://dis.4chan.org/read/prog/1295544154
11 result = []
12 emit = result.append
13 threads = [Thread(target=worker, args=(x, emit)) for x in s]
14 for t in threads:
15 t.start()
16 for t in threads:
17 t.join()
18 return result
19
20if __name__ == '__main__':
21 import random

Callers 1

recipe-577756.pyFile · 0.85

Calls 3

ThreadClass · 0.50
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected