Skip to content

Instantly share code, notes, and snippets.

@hatelove
Created July 26, 2013 10:43
Show Gist options
  • Save hatelove/6087948 to your computer and use it in GitHub Desktop.
Save hatelove/6087948 to your computer and use it in GitHub Desktop.
internal class CompoundComparer<T> : IComparer<T>
{
private readonly IComparer<T> primary;
private readonly IComparer<T> secondary;
internal CompoundComparer(IComparer<T> primary,
IComparer<T> secondary)
{
this.primary = primary;
this.secondary = secondary;
}
public int Compare(T x, T y)
{
int primaryResult = primary.Compare(x, y);
if (primaryResult != 0)
{
return primaryResult;
}
return secondary.Compare(x, y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment