Fixed sorting on joined table issue.