Solved

vb.net sort arraylist of dates

Posted on 2009-07-08
2
765 Views
Last Modified: 2012-05-07
Hi All,

I am looking for a simple example of sorting an arraylist of dates in descending order.

i am using VS2005, vb.net, .Net 2

Thanks
Zeus
0
Comment
Question by:Zeus2009
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 250 total points
Comment Utility
Coding can be found here: Sorting an arrayList of Dates
http://brijraj.spaces.live.com/Blog/cns!F3F32C257587DCC6!351.entry?sa=419549222
0
 
LVL 53

Expert Comment

by:Dhaest
Comment Utility
Another possibility:
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); });

Source: http://stackoverflow.com/questions/844251?sort=newest
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now