Er, actually not in theory. The current query seemed to work but maybe it was coincidence. I wanted to sort the Y values (descending) for each group of X values, then choose the first X,Y value (therefore the furthest down on the screen) to feed to another method. Perhaps I'm still confused about the IEnumerables that emerge from the LINQ query and how to access them properly.
Except when doing joins, I prefer to avoid the LINQ syntax and just use the Enumerable extension methods directly. It makes the behavior more clear, sometimes.
If you want things grouped by X and then each individual group sorted, you should do this:
var groups = invaders
.GroupBy(invader => invader.Location.X)
.Select(group => group.OrderByDescending(invader => invader.Location.Y));
If invaders looks like this: [(1,2), (1, 3), (1,1), (3, 5), (2, 4), (3, 4)] , then groups should look like this: [[(1, 3), (1, 2), (1, 1)], [(3, 5), (3, 4)], [(2, 4)]] (but you might want to double check that I'm right).
If you want LINQ syntax for that, you'd write
var groups = from invader in invaders
group invader by invader.Location.X into g
select g.OrderByDescending(invader => invader.Location.Y)
but I don't have a C# compiler on this computer so maybe I forgot something. This is equivalent:
var groups = from invader in invaders
group invader by invader.Location.X into g
select (from invader in g orderby invader.Location.Y descending select invader);