I agree with you -- for the functionality developed in the book, the CommentComparer class is not really necessary, as we are using the methods in question in only two places, and there is no need to reverse the order if you sort it they way you want directly in the SP. You'll also notice that CommentComparer allows for sorting by AddedBy as well as AddedDate, and that functionality is never used either.
I actually should say three places, as GetComments is also used in the Article class to define the Article.Comments property. However, I don't see a definite need to sort in descending order for that.
It is a good demonstration of how to implement IComparer though.
|