setupInfoList是一个泛型集合List
//pet为对象参数,可自定义;
JoinSetupid为我要分组的key
< IEnumerable> query = setupInfoList.GroupBy(pet => pet.JoinSetupid, pet => pet);
foreach (IGrouping info in query)
{
List sl=info.ToList();//分组后的集合
//也可循环得到分组后,集合中的对象,你可以用info.Key去控制
//foreach (KqiPageSetupInfo set in info)
//{
//}
}
http://blog.csdn.net/zyp_tfy/article/details/6122102
///升序
List<Customer> listCustomer1 = listCustomer.OrderBy(s => s.id).ToList<Customer>();
//降序
List<Customer> listCustomer2 = listCustomer.OrderByDescending(s => s.id).ToList<Customer>();
//Linq排序方式
List<Customer> listCustomer3 = (from c in listCustomer
orderby c.id descending //ascending
select c).ToList<Customer>();
http://blog.csdn.net/wanzhuan2010/article/details/6205884