CopyPastor

Detecting plagiarism made easy.

Score: 0.8080331683158875; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2012-07-20
by lasitha edirisooriya

Original Post

Original - Posted on 2009-05-09
by Guffa



            
Present in both answers; Present only in the new answer; Present only in the old answer;

you should not be using an `ArrayList` at all. You should use a strongly typed generic `List<DateTime>` instead.
For custom sorting there is an overload of the `Sort` method that takes a comparer. By reversing the regular comparison you get a sort in descending order:
list.Sort(delegate(DateTime x, DateTime y){ return y.CompareTo(x); });
###Update:
With lambda expressions in C# 3, the delegate is easier to create:
list.Sort((x, y) => y.CompareTo(x));
First of all, unless you are stuck with using framework 1.1, you should not be using an `ArrayList` at all. You should use a strongly typed generic `List<DateTime>` instead.
For custom sorting there is an overload of the `Sort` method that takes a comparer. By reversing the regular comparison you get a sort in descending order:
list.Sort(delegate(DateTime x, DateTime y){ return y.CompareTo(x); });
###Update:
With lambda expressions in C# 3, the delegate is easier to create:
list.Sort((x, y) => y.CompareTo(x));

        
Present in both answers; Present only in the new answer; Present only in the old answer;