asp.net - Sorting an array of dates -
i have created array csv of date values , need able sort them can latest date array.
i have tried:
array.sort()
but doesn't sort correctly, suppose because array values strings, body got ideas??
thanks help.
code used create array
'array string exampel: "19/07/2012,23/07/2012,23/07/2012,19/07/2012,25/07/2012" dim arrdates array = arrdates .split(",")
solution
dim arragentsreportcheck array = agentsreportcheck.split(",") dim arrdates new list(of date) integer = 0 arragentsreportcheck.length - 1 arrdates.add(arragentsreportcheck(i)) next arrdates.sort() dim latestdate date = arrdates.max()
as astander said, complicated sort array having datetime values. instead convert array list or arraylist , make life easy.
for arraylist can use following syntax:
list<datetime> dates = ... // init , fill dates.sort(); dates.reverse();
Comments
Post a Comment