216
brew
8y

Best sorting algorithm ever.
Sleep sort.
šŸ˜‚

Comments
  • 15
    Wondering, what is the complexity of this algorithm...
  • 8
    Why are you assuming that's a sorting algorithm?
  • 24
    @rusty-hacker because it prints the contents of the array in ascending order šŸ¤”
  • 9
    Faster sort ever = no sort.

    What..... I didn't even...how...oh well.
  • 6
    Should include check if user would not fall asleep before this function ends though
  • 20
    @codeJS cool. Try sorting neg numbers :)
  • 5
    Now add 1 integer. It shouldnt add much trouble right? 1 million šŸ˜‚šŸ‘
  • 1
    Ahaha that'sā€‹ amazing xD
  • 1
    doesn't work
  • 10
    There is a hope sort. Put numbers in an array and wait, hope array gets sorted.
  • 6
    It's easy to optimize if performance becomes problematic! Just add a / 100 somewhere.
  • 16
    Bubblesort, quicksort, bucketsort, timeoutsort, dinosort, wii sports resort...
  • 4
    @Huuugo That last one made me literally laugh out loud xD
  • 2
    @LicensedCrime lets update code with Math.log(val) :D
  • 1
    @rusty-hacker just normalize the numbers to be positive :) then undo it afterwards
  • 0
    @tylerhartwig not possible since you don't know in advanced what the lowest negative number will be.
  • 0
    @thejohnhoffer True.... You could do it for integers by switching signed to unsigned and back again, but you run into an issue on floats :/
  • 1
    Like counting sort, linear running time, with respect to number of bits in the largest integer in the array.
  • 0
    Python implementation for this???
  • 0
    lol that's hilarious! however instead of logging the output, why not use promises?
  • 0
    nice foreach sintax
  • 0
    Would that work on a really long array of numbers?

    Something like [1,3,...,2,....]

    If the array is long enough, won't the 3 timeout fire before the timeout of 2 is even created?
Add Comment