Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Common.Utilities
- {
- //var comp = new KeyComparer<string>((x, y) => string.Compare(x, y));
- /// <summary>
- /// Generic impl of <see cref="IComparer"/>
- /// </summary>
- /// <typeparam name="T">Type being compared</typeparam>
- public class KeyComparer<T> : IComparer<T>
- {
- private readonly Func<T, T, int> compareFunc;
- public KeyComparer(Func<T, T, int> compareFunction)
- {
- compareFunc = compareFunction;
- }
- public int Compare(T x, T y)
- {
- return compareFunc(x, y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment