All pastes #930478 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-06 16:54 UTC
rendered paste body
class 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);
    }
}