After getting a correct answer with my sorting issue, so I thought.
Whenever I would input any date with a 1 in it, 1 or 11, the sorted list would put that at the top regardless of the year. After I received an answer and implemented it, I entered 1/11/0000 and 11/1/0000 and it sorted correctly, so I thought I was home free. However, when I went back to some old test data and added a 11/1/0000 date, it shot right to the top again.
Did I miss something?
public class SortbyDate :IComparer<OilChange>
{
public int Compare(OilChange x, OilChange y)
{
DateTime dateX = Convert.ToDateTime(x.ServiceDate);
DateTime dateY = Convert.ToDateTime(y.ServiceDate);
return dateX.CompareTo(dateY);
}
}
Added this to the initial class, which seemed to work initially, but then…
Any thought as to what I’m doing or not doing?
The dates are saved as strings.