November
1:对包含数字的字符串按照数字的大小进行排序。
Code
1 using System;
2 using System.Text;
3
4 using System.Collections.Generic;
5 public class Test
6 {
7 static void Main()
8 {
9 string a="1";
10 string e="11";
11 string f="2";
12 string b="12";
13 string c="12#";
14 string d="13号";
15
16 List<string> list=new List<string>();
17 list.Add(a);
18 list.Add(b);
19 list.Add(c);
20 list.Add(d);
21 list.Add(e);
22 list.Add(f);
23 list.Sort();
24 Console.WriteLine("-------before");
25 foreach(string s in list)
26 {Console.WriteLine(s);}
27 list.Sort(Comparebystring);
28 Console.WriteLine("-------after sort");
29 foreach(string s in list)
30 {Console.WriteLine(s);}
31 }
32
33 class classlist
34 {
35 public List<string> TestList(string str1,string str2)
36 {
37
38 string a=str1+str2;
39 string b=str2+str1;
40 string c=str2+str2;
41
42 List<string> list=new List<string>();
43 list.Add(a);
44 list.Add(b);
45 list.Add(c);
46 list.Sort();
47
48 return list;
49 }
50 }
51
52 public static int Comparebystring(string x,string y)
53 {
54 int result=0;
55 if(String.IsNullOrEmpty(x)&&String.IsNullOrEmpty(y))
56 {return 0;}
57 else if(String.IsNullOrEmpty(x))
58 {return -1;}
59 else if(String.IsNullOrEmpty(y))
60 {return 1;}
61 else
62 {
63 StringBuilder left=new StringBuilder();
64 StringBuilder right=new StringBuilder();
65
66 foreach(char c in x)
67 {
68 if(c>='0' &&c<='9')
69 left.Append(c);
70 }
71 foreach(char c in y)
72 {
73 if(c<='9'&&c>='0')
74 right.Append(c);
75 }
76
77 int n=0;
78 int m=0;
79 Int32.TryParse(left.ToString(),out n);
80 Int32.TryParse(right.ToString(),out m);
81 result=n.CompareTo(m);
82
83 return result;
84 }
85
86 }
87 }
88
1 using System;
2 using System.Text;
3
4 using System.Collections.Generic;
5 public class Test
6 {
7 static void Main()
8 {
9 string a="1";
10 string e="11";
11 string f="2";
12 string b="12";
13 string c="12#";
14 string d="13号";
15
16 List<string> list=new List<string>();
17 list.Add(a);
18 list.Add(b);
19 list.Add(c);
20 list.Add(d);
21 list.Add(e);
22 list.Add(f);
23 list.Sort();
24 Console.WriteLine("-------before");
25 foreach(string s in list)
26 {Console.WriteLine(s);}
27 list.Sort(Comparebystring);
28 Console.WriteLine("-------after sort");
29 foreach(string s in list)
30 {Console.WriteLine(s);}
31 }
32
33 class classlist
34 {
35 public List<string> TestList(string str1,string str2)
36 {
37
38 string a=str1+str2;
39 string b=str2+str1;
40 string c=str2+str2;
41
42 List<string> list=new List<string>();
43 list.Add(a);
44 list.Add(b);
45 list.Add(c);
46 list.Sort();
47
48 return list;
49 }
50 }
51
52 public static int Comparebystring(string x,string y)
53 {
54 int result=0;
55 if(String.IsNullOrEmpty(x)&&String.IsNullOrEmpty(y))
56 {return 0;}
57 else if(String.IsNullOrEmpty(x))
58 {return -1;}
59 else if(String.IsNullOrEmpty(y))
60 {return 1;}
61 else
62 {
63 StringBuilder left=new StringBuilder();
64 StringBuilder right=new StringBuilder();
65
66 foreach(char c in x)
67 {
68 if(c>='0' &&c<='9')
69 left.Append(c);
70 }
71 foreach(char c in y)
72 {
73 if(c<='9'&&c>='0')
74 right.Append(c);
75 }
76
77 int n=0;
78 int m=0;
79 Int32.TryParse(left.ToString(),out n);
80 Int32.TryParse(right.ToString(),out m);
81 result=n.CompareTo(m);
82
83 return result;
84 }
85
86 }
87 }
88
2:RAID
3:SAS硬盘