int QuickSortForPermissions(WindowsGroupPermission x, WindowsGroupPermission y)
{
var px = x;
var py = y;
if(px == null || py == null)
{
return 1;
}
// New items must be last
//
if(px.IsNew)
{
// px is greater than py
return int.MaxValue;
}
if(py.IsNew)
{
// px is less than py
return int.MinValue;
}
// BuiltInAdministrators must be first
if(px.IsBuiltInAdministrators)
{
// px is less than py
return int.MinValue;
}
if(py.IsBuiltInAdministrators)
{
// px is greater than py
return int.MaxValue;
}
// IsBuiltInGuests must be second
if(px.IsBuiltInGuests)
{
// px is less than py
return int.MinValue + 1;
}
if(py.IsBuiltInGuests)
{
// px is greater than py
return int.MaxValue - 1;
}
return 1;
}