Is there a way to write this simpler?
if(criteria.SortBy =="name")
{
if (criteria.SortDirection == "ascending")
{
physicians.Sort((x, y) => string.Compare(x.Name, y.Name));
}
else
{
physicians.Sort((x, y) => string.Compare(y.Name,x.Name ));
}
}
if (criteria.SortBy == "birth")
{
if (criteria.SortDirection == "ascending")
{
physicians.Sort(new Comparison<Physician>((x, y) => DateTime.Compare(x.DateOfBirth ?? DateTime.MinValue,y.DateOfBirth ?? DateTime.MinValue)));
}
else
{
physicians.Sort(new Comparison<Physician>((x, y) => DateTime.Compare(y.DateOfBirth ?? DateTime.MinValue, x.DateOfBirth ?? DateTime.MinValue)));
}
}