IComparer Chapter 5 HELP PLEASE
On page 240 we have the following code:
public static List<Comment> GetComments(int articleID)
List<Comment> comments = GetComments(articleID, 0, BizObject.MAXROWS);
comments.Sort(new CommentComparer("AddedDate ASC"));
Now itís the Sort() method and our custom IComparer that is confusing me here. Now I know we use this Sort() method to sort our generic comments collection, and it will be sorted by the AddedDate property of the comment instances being compared, but Iím not sure how this is happening. Am I right to assume that by creating a new instance of our custom CommentComparer class within the Sort() method that the Compare() method it contains will execute automatically, and that all the comments in the collection are compared automatically using our Compare() method in order to determine the sort order?
If not then serious help needed here as I donít understand at all how this sort works. Please help.