Extract sorting info from the conditions

It's messed up otherwise, props @vgorni
Clarify the sums of squares condition