Add deterministic ordering to translate associations.

Having a deterministic ordering based on the primary key resolves
tests potentially failing when postgres returns data in a non-sequential
order.