Hi I have a generic list populated by a structure and sorts the contents of
the list based on the day and project # that is part of the structure. I
would like to modify it to also sort on the start time as the third sort
parameter? thanks.
public class Comparer : IComparer<mergeoutstruct>
{
public int Compare(mergeoutstruct a, mergeoutstruct b)
{
int result = DateTime.Compare(a.day, b.day);
if (result == 0)
{
result = a.projectnum.CompareTo(b.projectnum);
}
return result;
}
}
public struct mergeoutstruct
{
public Int32 projectnum;
public DateTime day;
public TimeSpan time;
public Double timeout;
public DateTime starttime;
public DateTime endtime;
}
Comparer comp = new Comparer(); //sorts by day and project #.
merglist.Sort(comp.Compare);
--
Paul G
Software engineer.