I have a list of objects. I sort this list by Code by writing this line:
Result.Sort(delegate(Position p1, Position p2) { return p1.Code.CompareTo(p2.Code); });
But I want to sort this line first by Code and then by Name. How to I do this?
Why won't you use LINQ?
var ordered = list.OrderBy(x => x.Code).ThenBy(x => x.Name).ToList();
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