Giter Site home page Giter Site logo

sleep_sort's Introduction

Sleep Sort

Are you tired of determining the time complexity of sorting algorithms? Are you tired of being asked which sorting algorithm is the best? Are you tired of wondering if your favorite programming language implements sorting in the most efficient manner?

If you answered "yes" to any of these questions then Sleep Sort is for you!

Example Usage

import random
from sleep_sort import Sleeper, ThreadSafeList

# a list of 20 random integers in the range [0, 100]
nums = [6, 85, 7, 17, 85, 56, 73, 41, 3, 84, 65, 43, 61, 69, 91, 96, 72, 14, 52, 83]

# create a thread-safe list object
sorted_list = ThreadSafeList()

# keeps a reference to all threads
threads = []

# starts a Sleeper thread for each item in the numbers list
for n in nums:
    
    # creates the thread
    sleeper = Sleeper(n, sorted_list)
    
    # starts the thread
    sleeper.start()
    
    # adds reference to thread to collection
    threads.append(sleeper)

# waits on all threads to finish before exiting
for thread in threads:
    thread.join()

# display the resulting sorted items
print(sorted_list)
[3, 6, 7, 14, 17, 41, 43, 52, 56, 61, 65, 69, 72, 73, 83, 84, 85, 85, 91, 96]

disclaimer: The models, methods, and general approach seen here are overly complex for the sake of clarity.

sleep_sort's People

Contributors

alphazwest avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.