对象自定义排序
public class JSForm: IComparer<JSForm>, IComparable<JSForm> { [Key] [Required] public int ID { get; set; } [Required] public string RowGuid { get; set; } public int IsDelete { get; set; } [Required] public string SendNumber { get; set; } //发货编号 public string ClientRowGuid { get; set; }//客户RowGuid public string ClientAddress { get; set; }//客户地址 public string ClientName { get; set; }//客户名称 public string ClientContactUser { get; set; }//客户联系人 public string SendDate { get; set; } //发货日期 public string WuLiuName { get; set; } //物流名称 public string WuLiuRowGuid { get; set; } public string WuLiuNumber { get; set; } public string CashCharge { get; set; } //现付费用 public string CashChargeDesc { get; set; } //对方付,我方付 public string SelfCharge { get; set; } // 自提费用 public string WuLiuUnitPrice { get; set; } public string BucketStyle { get; set; } //销桶,返桶,自带桶 public string BucketCount { get; set; } public string BucketPrice { get; set; } public string BucketSumPrice { get; set; } public string ActPay { get; set; } //实付 public string Manager { get; set; } public string SettlementModel { get; set; } //结算方式 public string IsNote { get; set; } //是否开票 public string IsContract { get; set; } //是否合同 public string Description { get; set; } public int Compare(JSForm j1, JSForm j2) { string sn1 = j1.SendNumber.Substring(4); string sn2 = j2.SendNumber.Substring(4); long v1 = Convert.ToInt64(sn1); long v2 = Convert.ToInt64(sn2); if (v1 > v2) return 1; if (v1 < v2) return -1; return 0; } public int CompareTo(JSForm js) { return Compare(this, js); } }