CSharp · Console
using System;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.DataSetExtensions;
using System.Data.Linq;
using System.Text;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
List<String> preferences = new List<String> { "first","second","third" };
List<string> mylist = new List<string>() {"four", "second", "first","third" };
IEnumerable<string> orderedData = mylist.OrderBy(item =>
{
var index = preferences.IndexOf(item);
return index>=0 ? index: int.MaxValue;
});
orderedData.Dump();
}
}