List<List1Dto> listResult = new List<List1Dto>();
listResult.Add(new List1Dto { UserName = "user1", UserPwd = "user1", UserTitle = "user1", OrderNumber = "1" });
listResult.Add(new List1Dto { UserName = "user2", UserPwd = "user2", UserTitle = "user2", OrderNumber = "2" });
listResult.Add(new List1Dto { UserName = "user10", UserPwd = "user10", UserTitle = "user10", OrderNumber = "10" });
listResult.Add(new List1Dto { UserName = "user20", UserPwd = "user20", UserTitle = "user20", OrderNumber = "20" });
List<List1Dto> list1 = listResult.OrderBy(ao => ao.OrderNumber).ToList();
string tmp = "";
foreach (List1Dto item in list1)
{
tmp += item.UserName + "\r\n";
}
结果:
user1
user10
user2
user20
修改:
List<List1Dto> list1 = listResult.OrderBy(ao => Convert.ToInt32( string.IsNullOrEmpty(ao.OrderNumber) ? "0" : ao.OrderNumber)).ToList();