Similar to this question, but in 2.0, we want to sort by one element, then another. we want to achieve the functional equivalent of SELECT * from Table ORDER BY x, y
We have a class that contains a number of sorting functions, and we have no issues sorting by one element. For example:
public class MyClass {
public int x;
public int y;
}
List<MyClass> MyList;
public void SortList() {
MyList.Sort( MySortingFunction );
}
And we have the following in the list:
Unsorted Sorted(x) Desired
--------- --------- ---------
ID x y ID x y ID x y
[0] 0 1 [2] 0 2 [0] 0 1
[1] 1 1 [0] 0 1 [2] 0 2
[2] 0 2 [1] 1 1 [1] 1 1
[3] 1 2 [3] 1 2 [3] 1 2
I think we are looking for some way to implement a stable sort, but I'm happy to take any suggestions!
edit:
OK, as often seems to be the case, the act of asking the question has released a mental block!
@nobugz - I implemented this just before I saw your answer! Thanks, that's the way to do it in this case. Except I don't use anonymous methods, 'cause I've got a few different sorts for this class.
@Jonathan Holland - If I need to add another sort I'll use something like yours!
@Bill The Lizard - that MS link refreshed my memory!