fix ternary order