C# Sort and OrderBy comparison
I can sort a list using Sort or OrderBy. Which one is faster? Are both working on same algorithm? List<Person> persons = new List<Person>(); persons.Add(new Person("P005", "Janson")); persons.Add(new Person("P002", "Aravind")); persons.Add(new Person("P007", "Kazhal")); 1. persons.Sort((p1,p2)=>string.Compare(p1.Name,p2.Name,true)); 2. var query = persons.OrderBy(n => n.Name, new NameComparer()); class NameComparer : IComparer<string> { public int Compare(string x,string y) { return string.Compare(x, y, true); } } Why not measure it: class Program { class NameComparer : IComparer<string> {