fix sorting by associations