只需创建所需的方法:
class City { public int CarbonId { get; set; } public static IOrderedEnumerableOrderByIrregularCarbonId( IEnumerable sequence, params int[] carbons) { return sequence.OrderBy(T => Array.IndexOf(carbons, T.CarbonId)); } } public static void Main(string[] args) { int[] carbonOrder = new[] { 3, 6, 2, 7, 9 }; List cities = City.OrderByIrregularCarbonId(db.GetCities, carbonOrder).ToList(); }