I am trying to sort my data in the array list.
For example the format of the data is as below:
“9:34 AM~Schedule 12” .
And i want it to sort according to the time only “9:34 AM~Schedule 12″ .
Below is the code to sort it but it doesn’t seem to work:
Array.Sort(timeSplit, delegate(string first, string second, string third)
{
return DateTime.Compare(Convert.ToDateTime(first), Convert.ToDateTime(second), third);
});
First you should remove the third string because the sort delegate only takes two parameters.
Second the data you pass it is not a valid
DateTimeyou should convert it to date time first.So: