First draft of new LINQ-based sorting.

All the pieces are in place, but it hasn't been tested yet.

I expect explosions.