List 简单升\降序实现

public class User
{
public int Id { get; set; }
public string Code { get; set; }
}

//示例

//升序
list.Sort(delegate(User v1, User v2)
{
return v1.Code.CompareTo(v2.Code);
});
//降序
//list.Sort(delegate(User v1, User v2)
//{
// return v2.Code.CompareTo(v1.Code);
//});

你可能感兴趣的:(list)