15

Came across this sorting function in JS, should it be allowed?

Comments
  • 9
    The shittier version of this,

    https://devrant.com/rants/445614
  • 2
    What if you pass in a negative number...
  • 0
    @kamen it doesn't sort
  • 2
    Thanks, I hate it
  • 1
    @UnSorted You don't say. That was a rhetorical question.
  • 10
    @kamen it travels to the past. So by the time you execute the program, the numbers will be already sorted.
  • 1
    @kamen Time travel,duh.
  • 1
    Using the array.forEach method to generate an even shittier version of array.sort.

    Nuke them. Burn it all.
  • 2
    Ain't no one else focused on the fact that this will cause a macro task to be added for each array item? Meaning the time to process this could be delayed for no reason by a different task.
  • 0
    Oh this is pure gold.

    I mean it’s shit, won’t work for negatives, and of course will take as long as the sum of the numbers (in ms) to complete, but I still love it.

    It’s like the Rain Man of array sorts.
  • 1
    @iiii Oh, yup, you're right...

    It would just be the largest number plus enough time to process the foreach loop because all the setTimouts would essentially run concurrently, my mistake.
  • 0
    @HiFiWiFiSciFi that answers a few questions
  • 0
    Im already thinking of application of this :D
Add Comment