I am getting a strange behavior with the OrderBy()
Method of Lists
.
Imagine you have a List and each Person has Firstname
, Lastname
and Gender
.
If all People in this list are of Gender
"m"
, I will get a different sorting after each call of
list.OrderBy(p => p.Gender)
But I don't want my list to jump around on each and every refresh. Any idea on this?
You can use ThenBy()
to sort it using other properties if Gender is same. Like this:
list.OrderBy(p=>p.Gender).ThenBy(p=>p.FirstName);
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