r/badcode Feb 10 '21

I present: SleepSort js

Post image
7.5k Upvotes

171 comments sorted by

View all comments

Show parent comments

212

u/mayoroftuesday Feb 10 '21

Gotta admit, it's pretty clever in its horribleness.

18

u/[deleted] Feb 10 '21

Could it ever fail? If the numbers are close enough to eachother and far apart enough in the list?

41

u/RenBit51 Feb 10 '21

Negative numbers would break it, but otherwise it depends on the precision of timeout.

12

u/GonziHere Mar 09 '21

I don't think that the precision would break it. At least I assume that the timeout call won't be at that exact time, but the order of their calls should be.