...which is O(1). You need to pretend every algorithm runs with arbitrary-sized ints and infinite memory, otherwise the fact that a computer has limited memory means it has a finite number of states and all algorithms are O(1).
Instead, i'd call this O(M) where M is the largest input, or O(2W ) where W is the bit width.
Not much.. As far as I know Task.Delay will use OS thread sheduling to wake up. So the resolution will be around 16ms. So everything in same 16ms block wil be sorted randomly. (There is probably optimisation to launch other task when task completes, but in this case everything is sleeping)
I mean... You can easily change it from printing to add to the new sorted list or something (I know it's a bad solution, but sorting using timeouts wasn't supported to be good) ;)
You were probably trolling, but it is not brilliant at all. Try it with a list with all numbers from 1 to 10 and I can guarantee you that it will never work.
There are subs for humour and subs for serious things. It is just the wrong place to post that. Imagine if every one starts posting crap like this, we won't be able to see what's serious and worth of our time and what is not.
I don't know what's up with people wanting to police this subreddit so much. It's not like there are two hundred posts a day. I enjoy it just the way it is.
Jokes are allowed. There's even a "Fun" flair available for them.
Rule 7 generally covers more blogspam and introductory tutorials like "Here's a 'Hello World!' application" and very poorly constructed articles/blogs (to the level that they don't even indent code.)
It's fine for a fun post like this, especially when you're not expected to be copy/pasting the code. For debugging, it's not ideal, but it's usually enough to get by.
I was going to copy this straight into my current project, but the image and lack of appropriate licensing means I'm going to be relying on hope that my lists are sorted. Thanks OP :(
Bah, just throw some optical character recognition library at it, load it from the jpg and compile an assembly at runtime. As for licensing, any code posted to /r/csharp without an explicit license automatically falls under WTFPL. So go nuts. #notlegaladvice
This is great. There are often multiple ways to do stuff in programming, and this is a clear demonstration that getting the correct output is not the only goal.
It also shows thinking outside the box, yes in this case it gives a worse solution, but often spinning stuff around like this reveals a better solution.
I'm sure we spoke the other day because I remember your username. Please never say anything I need to quote in an interview as I like to cite my references :)
150
u/chucker23n Aug 11 '20
If you change it to
Task.Delay(i / 2), it runs twice as fast!67
u/nminaya Aug 11 '20
This is pretty much SleepSort
11
u/Atulin Aug 11 '20
Now figure out what big-O complexity it has lol
24
u/ipocrit Aug 11 '20
Lawful evil
7
u/readmond Aug 11 '20
Quick sorting could be unreliable. Slow down a bit to get the correct results.
5
u/CodeMonkeyMark Aug 11 '20
I’m a big fan of your development work. - Satan
9
u/thestamp Aug 11 '20
Lord have mercy
8
u/zenyl Aug 11 '20
/r/Angryupvote, but funny. :)
3
u/ExeusV Aug 11 '20
Looks good, but how does it compete with?
5
u/[deleted] Aug 11 '20
Stupid code tricks.
4
u/Mr_Cochese Aug 11 '20
Haha, no.
0
u/hieplenet Aug 12 '20
the more interesting question would be..."how reliable is this? Pls explain."
-36
u/FasinThundes Aug 11 '20
If it were actually sorting the array, that would be fun! But as it stands, this just prints to console and does no sorting at all.
-55
u/KryptosFR Aug 11 '20
You were probably trolling, but it is not brilliant at all. Try it with a list with all numbers from 1 to 10 and I can guarantee you that it will never work.