Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 802
  • Last Modified:

vb.net sort arraylist of dates

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
Zeus2009
Asked:
Zeus2009
  • 2
1 Solution
 
DhaestCommented:
Coding can be found here: Sorting an arrayList of Dates
http://brijraj.spaces.live.com/Blog/cns!F3F32C257587DCC6!351.entry?sa=419549222
0
 
DhaestCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now