Sort traits by name.

This fixes the first problem described in #2734.