Order "when" clause by output_type