using System.Collections.Generic;
public static void Main(string[] args)
Console.WriteLine("Hello World!");
var list = new[]{"Foobar", "Baz", "Foo", "Foobar", "Bar", };
Array.Sort(list, new CustomComparer(new[]{"Foo", "Bar", "Baz", "Foobar"}));
public class CustomComparer : IComparer<string>
private readonly string[] priorityList = {"Foo", "Bar", "Baz", "Foobar"};
public CustomComparer(string[] priorityList)
this.priorityList = priorityList;
public int Compare(string x, string y)
var xIx = Array.IndexOf(priorityList, x);
var yIx = Array.IndexOf(priorityList, y);
return xIx.CompareTo(yIx);