Mine
public text v1 · immutableclass ReverseComparer<T> : IComparer<T>
{
readonly IComparer<T> defaultComparer = Comparer<T>.Default;
static IComparer<T> instance;
static object lockObj = new object();
private ReverseComparer()
{
}
public IComparer<T> Default
{
get
{
if (instance == null)
{
lock (lockObj)
{
if (instance == null)
{
instance = new ReverseComparer<T>();
}
}
}
return instance;
}
}
public int Compare(T x, T y)
{
return -1 * defaultComparer.Compare(x, y);
}
}