Parentheses to ensure operator priority
Created by: adamwight
Boolean operators bind with higher priority than the ternary operator, so these must be protected with parentheses.
Some test results change because we were previously sorting in a quirky, out-of-order way.