第一种方法:
int[] orderArr = new int[]{ 3, 2, 1, 4, 5 };
listCustomer = listCustomer.OrderBy(e =>
{
var index = 0;
index = Array.IndexOf(orderArr, Convert.ToInt32(e.cType));
if (index != -1) { return index; }
else
{
return int.MaxValue;
}
}).ToList();
第二种方法:
int[] orderArr = new int[]{ 3, 2, 1, 4, 5 };
listCustomer.OrderBy(t=>Array.IndexOf(orderArr,Convert.ToInt32(e.cType))).ToList();
排序的字段必须为对应的类型,否则排序无效