I have a list of an object which need to be sorted depending on three different properties of the object. Example
CLass Object1{ Property1 , Property2, Property3}
ListObj = IEnumerable<Object1>
Foreach ( item in ListObj){
if (item.Property1 == true)
item goes at top of list
if(item.Property2 == true)
item goes end of list
if(item.Property3 == true)
item can go anywhere.
}
End list should be objects with Property1 = true followed by objects with Property2 = true followed by objects with Property3 = true
Why not use LINQ?
var orderedList =
ListObj.OrderByDescending(x => x.Property1)
.ThenByDescending(x => x.Property2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With