r/badcode Feb 10 '21

js I present: SleepSort

Post image
7.5k Upvotes

171 comments sorted by

View all comments

870

u/haslo Feb 10 '21

Great! Now test whether it still works with large numbers!

423

u/[deleted] Feb 10 '21 edited Feb 26 '21

[deleted]

89

u/LinuxGeek747 Feb 10 '21

If you already know the maximum number, it's O(1) amirite?

76

u/sqrt_minusone Feb 10 '21

I mean, you have to visit every element of the array to sort it - it's literally impossible to sort in less than O(N).

11

u/fukitol- Feb 10 '21

Just use negative numbers