1 Class Program
2 {
3 Static Void Main ( String [] ARGs)
4 {
5 Employee [] employees =
6 {
7 New Employee ( " Bugs Bunny " , 20000 ),
8 New Employee ( " Elmer Fudd " , 10000 ),
9 New Employee ( " Daffy Duck " , 25000 ),
10 New Employee ( " Wile Coyote " , 1000000.38 m ),
11 New Employee ( " Foghorn Leghorn " , 23000 ),
12 New Employee ( " Roadrunner " , 50000 )
13 };
14 Bubblesorter. Sort (employees, employee. comparesalary );
15 Foreach (VAR employee In Employees)
16 {
17 Console. writeline (employee );
18 }
19 Console. Readline ();
20 }
21 }
22
23 Class Bubblesorter
24 {
25 Static Public Void Sort < T > (Ilist < T > Sortarray, func < T, T, Bool > Comparison)
26 {
27 Bool Swapped = True ;
28 Do
29 {
30 Swapped = False ;
31 For ( Int I = 0 ; I < Sortarray. Count - 1 ; I ++ )
32 {
33 If (Comparison (sortarray [I + 1 ], Sortarray [I])
34 {
35 T temp = Sortarray [I];
36 Sortarray [I] = Sortarray [I + 1 ];
37 Sortarray [I + 1 ] = Temp;
38 Swapped = True ;
39 }
40 }
41 } While (Swapped );
42 }
43 }
44
45 Class Employee
46 {
47 Public Employee ( String Name, Decimal Salary)
48 {
49 This . Name = Name;
50 This . Salary = Salary;
51 }
52 Public String Name { Get ; Private Set ;}
53 Public Decimal Salary { Get ; Private Set ;}
54 Public Override String Tostring ()
55 {
56 Return String . Format ( " {0}, {1: c} " , Name, salary );
57 }
58 Public Static Bool Comparesalary (employee E1, employee E2)
59 {
60 Return E1.salary < E2.salary;
61 }
62 }