I have a List
with dates.
My list is:
{\"01/01/2013\",\"10/01/2013\",\"20/01/2013\"}
I want to sort the list
You shouldn't use string representations of data - we're all living in object-oriented world :)
Best way would be to convert these strings into actual DateTime objects and sort them in reverse order via linq:
var dates = Array.ConvertAll(dateStrings, x => DateTime.Parse(x));
return dates.OrderByDesc(x => x);
Another way would be to implement custom sorting function, see this link. Then you'd just use it in a sort function:
DateAsStringComparer myComparer = new DateAsStringComparer();
dateStrings.Sort(myComparer);