public int Compare(object x, object y) {
Debug.Assert(x != null && x is TemplateAction);
Debug.Assert(y != null && y is TemplateAction);
TemplateAction tx = (TemplateAction) x;
TemplateAction ty = (TemplateAction) y;
Debug.Assert(! Double.IsNaN(tx.Priority));
Debug.Assert(! Double.IsNaN(ty.Priority));
if (tx.Priority == ty.Priority) {
Debug.Assert(tx.TemplateId != ty.TemplateId || tx == ty);
return tx.TemplateId - ty.TemplateId;
}
else {
return tx.Priority > ty.Priority ? 1 : -1;
}
}
}