I want to sort a Generic List in Ascending Date order. (Framework v2)
Any suggestions?
Upul and Wim said it all:
Use delegates:
new List().Sort(delegate(DateTime d1, DateTime d2) {
return d1.CompareTo(d2);
});
Or if you have a class or something that holds that datetime:
new List().Sort(delegate(Nhonho n1, Nhonho n2) {
return n1.date.CompareTo(n2.date);
});
To make it lessening,
new List().Sort(delegate(Nhonho n1, Nhonho n2) {
return n2.date.CompareTo(n1.date);
});
Good luck.