drupal hit counter
Jerry Huang | just for fun: sleep sort

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
	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);}}}