Sort sets by cycle number first, then code.