Here parent class has child class in child class we have name how to make the list of parent as orderby using name property of child class. I used pq.OrderBy(z => z.Class1.Name != null).ToList(); but the list is not ordered as expected.
class Program
{
static void Main(string[] args)
{
List<Parent> pq = new List<Parent>() {
new Parent () { Class1=new Child () { Name="d" } },
new Parent () { Class1=new Child () { Name="s" } },
new Parent () { Class1=new Child () { Name="y" } },
new Parent () { Class1=new Child () { Name="r" } },
new Parent () { Class1=new Child () { Name="b" } },
new Parent () { Class1=new Child () { Name="a" } }
};
var assa = pq.OrderBy(z => z.Class1.Name != null).ToList();
}
}
public class Parent
{
public Child Class1 { get; set; }
}
public class Child
{
public string Name { get; set; }
}