In this topic: How to sort list with complex object by one of its properties? is explained how to sort by a property, but how to sort by two?
Considering the following product class:
+-------------------+--------------------+
| Produto |
+-------------------+--------------------+
| Código | int |
| Nome | string |
| Preço | double |
| Categoria | Categoria |
+-------------------+--------------------+
And the category class
+-------------------+--------------------+
| Categoria |
+-------------------+--------------------+
| Código | int |
| Nome | string |
+-------------------+--------------------+
And imagining a list of products.
How can I sort the list alphabetically by the name of its category, followed by alphabetical order of the name itself? Is it possible to use IComparer
?