drupal hit counter
Jerry Huang | All posts tagged 'sleepsort'

Jerry Huang apps and developing apps

just for fun: sleep sort

29. June 2011 15:02 by Jerry in C#

there are some other versions of implementation in different programming languages, here is my c# version and I believe this sort algorithm will be very hot soon:)

[code language=C#]
using System;
using System.Collections.Generic;
using System.Text;

namespace SleepSort
{
    class Program
    {
       
        static void Main(string[] args)
        {
            int[] ints = { 1, 4, 2, 6, 3 };
            foreach (int i in ints)
            {
                SleepSort ss = new SleepSort(i);
                System.Threading.Thread t = new System.Threading.Thread(ss.Sort);
                t.Start();
            }

        }

       
    }

    public class SleepSort
    {
        int i;
        public  SleepSort(int i)
        {
            this.i = i;
        }

        public void Sort()
        {
            System.Threading.Thread.Sleep(i);
            Console.WriteLine(i);
        }
    }
}
[/code]