我想在 List 上进行排序,例如:
public List<Person> personList { get; set; };
class Person
{
public string Name{ get; set; };
public List<Car> carList{ get; set; };
}
class Car
{
public string Name { get; set; };
public int PriceInMillions { get; set; };
}
我想对列表顶部的CarList
每一个PersonList
进行CarList
排序?BMW object(can be one or more)
输入:
Person: Name: 'ABC'
List<Car>:{{"x",25},{"y",25},{"BMW",26},{"x",25},{"BMW",25}}
Person: Name: 'DEF'
List<Car>:{{"BMW",21},{"y",25},{"BMW",26},{"x",25},{"BMW",20}}
所需输出:
Person: Name: 'ABC'
List<Car>:{{"BMW",25},{"BMW",26},{"x",25},{"y",25},{"x",25}}
Person: Name: 'DEF'
List<Car>:{{"BMW",20},{"BMW",21},{"BMW",26},{"y",25},{"x",25}}
我试图找到“BMW”的索引并将其与第一个索引交换,但它不起作用。