Question: What is the largest open source project written in Visual C++ ?

I can see that eMule project is pretty big, but what is largest?

Answer: 
Not really efficient for large lists but fairly easy to read:

```
public class FixedOrderComparer<T> : IComparer<T>
{
    private readonly T[] fixedOrderItems;

    public FixedOrderComparer(params T[] fixedOrderItems)
    {
        this.fixedOrderItems = fixedOrderItems;
    }

    public int Compare(T x, T y)
    {
        var xIndex = Array.IndexOf(fixedOrderItems, x);
        var yIndex = Array.IndexOf(fixedOrderItems, y);
        xIndex = xIndex == -1 ? int.MaxValue : xIndex;
        yIndex = yIndex == -1 ? int.MaxValue : yIndex;
        return xIndex.CompareTo(yIndex);
    }
}

```

Usage:

```
var orderedData = data.OrderBy(x => x, new FixedOrderComparer<string>("A", "B", "C"));

```

Note: `Array.IndexOf<T>(....)` uses `EqualityComparer<T>.Default` to find the target index.
I use these. I like the IEnumerable overload for cleanliness, but the priority map version should have better performance on repeated calls.

```
    public static IEnumerable<T> OrderByStaticList<T>(this IEnumerable<T> items, IReadOnlyDictionary<T, double> priorityMap)
    {
        return items.OrderBy(x => priorityMap.GetValueOrDefault(x, double.MaxValue));
    }

    public static IEnumerable<T> OrderByStaticList<T>(this IEnumerable<T> items, IEnumerable<T> preferenceOrder)
    {
        int priority = 0;
        var priorityMap = preferenceOrder.ToDictionary(x => x, x => (double) priority++);
        return OrderByStaticList(items, priorityMap);
    }

    [TestMethod]
    public void PriorityMap_DeterminesSort()
    {
        var map = new Dictionary<char, double>()
        {
            {'A', 1},
            {'B', 7},
            {'C', 3},
            {'D', 42},
            {'E', -1},
        };
        Assert.AreEqual("EACBD", new string("ABCDE".OrderByStaticList(map).ToArray()));
    }

    [TestMethod]
    public void PriorityMapMissingItem_SortsLast()
    {
        var map = new Dictionary<char, double>()
        {
            {'A', 1},
            {'B', 7},
            {'D', 42},
            {'E', -1},
        };
        Assert.AreEqual("EABDC", new string("ABCDE".OrderByStaticList(map).ToArray()));
    }

    [TestMethod]
    public void OrderedList_DeterminesSort()
    {
        Assert.AreEqual("EACBD", new string("ABCDE".OrderByStaticList("EACBD").ToArray()));
    }

    [TestMethod]
    public void OrderedListMissingItem_SortsLast()
    {
        Assert.AreEqual("EABDC", new string("ABCDE".OrderByStaticList("EABD").ToArray()));
    }

```