Sort types function
First pass