[C#] Help with understanding the Comparison delegate with List.Sort() method
Hey everyone, I have a question. I am learning C#, and I love it so far :) I am struggling a bit in understanding the usage of the "Comparison" delegate when invoked via the List.Sort() method. So basically, I am trying to sort a list of strings in a list, and one solution that came across is using a lambda function with the "sort()" method as follows: List<string> wordDictionnary = new List<string>(); wordDictionnary.Add("John"); wordDictionnary.Add("Elena"); wordDictionnary.Add("Genevieve"); wordDictionnary.Sort((x, y) => x.Length - y.Length); Although I do understand lambdas functions, and the fact that the first overload of the method is the invocation of the "Comparison<T>" delegate, I don't understand how this works. My understanding is that x and y are simply two instances of the list (?) passed as parameters to the delegate function. But how is the function able to compare the two lists? How does it iterate over each word in the list to determine their length? What's even more confusing for me is that the official documentation shows the prototype of that comparison delegate: > https://docs.microsoft.com/en-us/dotnet/api/system.comparison-1?view=netframework-4.8#examples "dinosaurs.Sort(CompareDinosByLength);" In this example, the method is invoked without any param., although it requires two params. How does that work? How is that function able to extract "x" and "y"? Thanks for your guidance fellow sololearners :)