Created
June 16, 2011 18:11
-
-
Save renestein/1029851 to your computer and use it in GitHub Desktop.
Stupid sort based on http://dis.4chan.org/read/prog/1295544154
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Stupid "Schrodinger sort (cat not involved!)" based on http://dis.4chan.org/read/prog/1295544154 - great antipattern | |
static void Main(string[] args) | |
{ | |
int[] xs = new[] { 5, 3, 6, 3, 6, 3, 1, 4, 7}; | |
var results = new ConcurrentQueue<int>(); | |
Console.WriteLine("Sorted:"); | |
Parallel.ForEach(xs, n => | |
{ | |
Thread.SpinWait(n); //Thread.Sleep(n); | |
results.Enqueue(n); | |
} | |
); | |
results.ToList().ForEach(n => Console.WriteLine(n)); | |
Console.ReadLine(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment