Linq OrderBy against specific values
If you put your preferences into a list, it might become easier. List<String> data = new List<String> { “A”,”B”,”A”,”C”,”B”,”C”,”D”,”E” }; List<String> preferences = new List<String> { “A”,”B”,”C” }; IEnumerable<String> orderedData = data.OrderBy( item => preferences.IndexOf(item)); This will put all items not appearing in preferences in front because IndexOf() returns -1. An ad hoc work around … Read more