对包含list的对象列表按顺序排序
本文关键字:顺序 排序 列表 对象 包含 list | 更新日期: 2023-09-27 18:11:29
我有这个对象:
public class humanInfo
{
public string m_Name { get;set; }
public List<HumanAttributes> m_ListHumanAttributes { get; set;}
}
我想根据Age
属性对这个列表进行排序,该属性位于每个人的属性列表中。
humanList = humanList.OrderBy(/*How am I gonna do this?*/);
我已经尝试使用x => x.m_ListHumanAttributes.All()
获得所有项目,例如,但我对如何进行有点无能为力。有人有好主意吗?
编辑
下面是HumanAttributes
类如何工作的想法:
public class HumanAttributes
{
public int m_HumanAttributesID {get;set;}
public Sex m_HumanAttributeSex {get;set;}
public int m_HumanAge {get;set;}
public decimal m_HumanHeight {get;set;}
}
假设HumanAttributes具有Name和Value属性:
humanList.OrderBy(h=>h.ListHumanAttributes.First(a=>a.Name=="Age").Value);