Constant-composition codes are a special class of constant-weight codes with very strong constraints. It is hard to construct optimal constant-composition codes. There are only a few classes of such optimal codes in the literature. In this correspondence, a family of optimal ternary constant-composition codes is constructed from a class of newly discovered perfect nonlinear functions. This class of codes is related to a new family of skew Hadamard difference sets which are the only examples of such difference sets discovered in the last seventy years.