Add sorting by BelongsTo relations
Improved order by logic