Created
February 10, 2012 09:53
-
-
Save alexandru-calinoiu/1788161 to your computer and use it in GitHub Desktop.
A C# implementation of Sleep Sort inspired by this talk http://www.infoq.com/presentations/Cool-Code
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace SleepSort | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var numbers = new List<int> {4, 6, 5, 10}; | |
int min = numbers.Min(); | |
Parallel.ForEach(numbers, number => | |
{ | |
Thread.Sleep((number - min) * 1000); | |
Console.WriteLine(number); | |
}); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment