主程序代码
newsCompare newsCompare = new ItemManage.newsCompare(); newsList.Sort(newsCompare);
自定义类代码(按照CREATEDATE属性排序)
class newsCompare : IComparer { int System.Collections.IComparer.Compare(object x, object y) { TJZB_GDNEWS model1 = new TJZB_GDNEWS(); TJZB_GDNEWS newsX = (TJZB_GDNEWS)x; TJZB_GDNEWS newsY = (TJZB_GDNEWS)y; if (newsX.CREATEDATE > newsY.CREATEDATE) return -1; if (newsX.CREATEDATE < newsY.CREATEDATE) return 1; return 0; } }