How do I sort ArrayList of DateTime objects in descending order?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, unless you are stuck with using framework 1.1, you should not be using an
ArrayListat all. You should use a strongly typed genericList<DateTime>instead.For custom sorting there is an overload of the
Sortmethod that takes a comparer. By reversing the regular comparison you get a sort in descending order:Update:
With lambda expressions in C# 3, the delegate is easier to create: