In the class that implements Compare you need to add two fields/properties:
private Feature _alwaysFirst;
private Feature _alwaysLast;
And do this in your comparer:
public int Comparer(Feature left, Feature right)
{
if (left == _alwaysFirst)
return 1;
if (left == _alwaysLast)
return -1;
return string.Compare(left.FirstName, right.FirstName);
}
This architecture allows you to select just one Feature (employee) to appear first, and just one to appear last.
Note that names are not unique, so I don't recommend making _
alwaysFirst
and _
alwaysLast
strings, and comparing against
left.FirstName
. Sure, it would group all elements of the list which have identical first/last names that match the _
alwaysXXX
names at the beginning/end, but it wouldn't sort within those groups (well, you'd have do some other compare instead of returning 1/-1 to get sorting within those groups).