Sort types

Tested yesterday with Andrew, and it works.