Better sorting of relation types