Fixes sort on polymorphic association #421

This should fix the sorting on the polymorphic associations. Please have a look and let me know if there are any problems. Thanks!