Generate m2m rels in deterministic order