Skip to content

Instantly share code, notes, and snippets.

@alexandru-calinoiu
Created February 10, 2012 09:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandru-calinoiu/1788161 to your computer and use it in GitHub Desktop.
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
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