static bool LessThan(Row r1, Row r2, string propertyName)
{
var property = typeof(Data.DescriptionInfo).GetProperty(propertyName);
if (property != null)
{
var p1 = property.GetValue(r1.Device.Description, null);
var p2 = property.GetValue(r2.Device.Description, null);
string s1 = p1 != null ? p1 as string : null;
string s2 = p2 != null ? p2 as string : null;
// Check for null values and put them at the bottom of the list
if (string.IsNullOrEmpty(s1) && string.IsNullOrEmpty(s2)) return false;
if (string.IsNullOrEmpty(s1) && !string.IsNullOrEmpty(s2)) return false;
if (!string.IsNullOrEmpty(s1) && string.IsNullOrEmpty(s2)) return true;
// Evaluate property comparison
return string.Compare(s1, s2) <= 0;
}
return false;
}