Comparer that compares by int than by enum type Below is the implementation of a comparer that compares objects of type Region first by index and then by it's type. The sort order of the type is defined within the comparer.

I know, it's a trivial piece of code, however I am happy about any comments about the realization. :)

public class Region
{
    public RegionType Type { get; set; }
    public int Index { get; set; }
}

public enum RegionType
{
    DeletionBeforeNamedRegion,
    DeletionWithinNamedRegion,
    DeletionAfterNamedRegion,
    InsertionBetweenNamedRegions,
    InsertionWithinNamedRegion,
    NamedRegion,
}

public class RegionComparer : IComparer&lt;Region&gt;
{
    private static readonly List&lt;RegionType&gt; sortOrderByType = new List&lt;RegionType&gt;
        {
            RegionType.DeletionBeforeNamedRegion,
            RegionType.NamedRegion,
            RegionType.DeletionWithinNamedRegion,
            RegionType.InsertionWithinNamedRegion,
            RegionType.DeletionAfterNamedRegion,
            RegionType.InsertionBetweenNamedRegions,
        };

    public int Compare(Region x, Region y)
    {
        if (x == null &amp;&amp; y == null)
            return 0;
        if (x == null) return -1;
        if (y == null) return 1;

        var result = x.Index.CompareTo(y.Index);
        if (result != 0) return result;

        var xSort = sortOrderByType.IndexOf(x.Type);
        var ySort = sortOrderByType.IndexOf(y.Type);

#if DEBUG
        if (xSort &lt; 0 || ySort &lt; 0)
            throw new NotImplementedException($"Sort order for region type '{(xSort &lt; 0 ? x.Type : y.Type)}' is not defined. Please extend the '{nameof(sortOrderByType)}' list." );
#else
        if (xSort &lt; 0) xSort = int.MaxValue;
        if (ySort &lt; 0) ySort = int.MaxValue;
#endif
        return xSort.CompareTo(ySort);
    }
}
private static readonly List&lt;RegionType&gt; sortOrderByType = new List&lt;RegionType&gt;
{
    RegionType.DeletionBeforeNamedRegion,
    RegionType.NamedRegion,
    RegionType.DeletionWithinNamedRegion,
    RegionType.InsertionWithinNamedRegion,
    RegionType.DeletionAfterNamedRegion,
    RegionType.InsertionBetweenNamedRegions,
};


Sorting needs to be fast, right? So how about using a dictionary for the oder lookup and not the O(n) List.IndexOf?
private static readonly Dictionary&lt;RegionType, int&gt; _regionTypeOrder = new RegionType[] 
{
    RegionType.DeletionBeforeNamedRegion,
    RegionType.NamedRegion,
    RegionType.DeletionWithinNamedRegion,
    RegionType.InsertionWithinNamedRegion,
    RegionType.DeletionAfterNamedRegion,
    RegionType.InsertionBetweenNamedRegions,
}
.Select((x, i) =&gt; new { Key = x, Order = i })
.ToDictionary(x =&gt; x.Key, x =&gt; x.Order);

with it, the lines

var xSort = sortOrderByType.IndexOf(x.Type);
var ySort = sortOrderByType.IndexOf(y.Type);


can become
var xSort = _regionTypeOrder[x.Type];
var ySort = _regionTypeOrder[y.Type];



var xSort = sortOrderByType.IndexOf(x.Type);
var ySort = sortOrderByType.IndexOf(y.Type);

if (xSort &lt; 0) xSort = int.MaxValue;
if (ySort &lt; 0) ySort = int.MaxValue;


the index should never be less then zero. If it is, then there is an error. Its an enum and the property isn't nullable so I think the protection isn't necessary.
After getting ther RegionType order from the dictionary you should be able to immediately call this

return xSort.CompareTo(ySort);