0

I want to sort the collection before processing. I used to use this method:

foreach (var item in Items.OrderBy(i => i.property1))
{
 ...
}

Now i need to sort it by property2, if property values is equals between two items. Is there any method to do that logic via LINQ expression?

John Grave
  • 13
  • 1
  • 4

1 Answers1

4

Is this what you're after?

foreach (var item in Items.OrderBy(i => i.property1).ThenBy(i => i.property2))
{
 ...
}
Enigmativity
  • 97,521
  • 11
  • 78
  • 153