For many years, the courts of appeals of this country understood the prohibition against sex discrimination to exclude discrimination on the basis of a person’s sexual orientation,” Chief Judge Diane Wood wrote for the majority.