Я писал другой пример, пока t4rzsan ответил =) Я предпочитаю ответ t4rzsan ... в любом случае, это ответ, который я писал.
//Like ob says, you could create your custom string comparer
public class MyStringComparer : IComparer<string>
{
public int Compare(string x, string y)
{
// Return -1 if string x should be before string y
// Return 1 if string x should be after string y
// Return 0 if string x is the same string as y
}
}
Пример использования вашего собственного строкового компаратора:
public class Program
{
static void Main(string[] args)
{
List<string> MyList = new List<string>();
MyList.Add("smtp:user@domain.com");
MyList.Add("smtp:user@otherdomain.com");
MyList.Add("SMTP:user@anotherdomain.com");
MyList.Sort(new MyStringComparer());
foreach (string s in MyList)
{
Console.WriteLine(s);
}
Console.ReadLine();
}
}