If I want to order a list based on more than one property, I can't see a good way of doing that other than forming those properties to numbers and then using OrderBy
, for instance:
int someArbitraryNumber = 1000;
List<Tuple<int, int>> test = new List<Tuple<int, int>>() {
new Tuple<int, int>(1, 3),
new Tuple<int, int>(1, 4),
new Tuple<int, int>(1, 5),
new Tuple<int, int>(2, 3),
new Tuple<int, int>(9, 15)
};
var orderedTest = test
.OrderBy(x => x.Item1 + x.Item2 * someArbitraryNumber);
Here I'd be looking to for the resulting list to be:
(1, 3),
(2, 3),
(1, 4),
(1, 5),
(9, 15)
That is to say, first ordered by the second item, then by the first.