Relationship between groups that have the same group of homomorphisms to another group Say, there are two groups $A$ and $B$. We are given that $\mathrm{Hom}(A,G)$ and $\mathrm{Hom}(B,G)$ are isomorphic, where $G$ is another group that may or may not be trivial. What can we say about the relationship between $A$ and $B$?
Not really a homework problem, just wondering.

If $G$ is just a single fixed group, then one can say very little about $A$ and $B$. For instance, if $G$ is a one-element group, then the hom groups are always isomorphic. Requiring the hom groups to be isomorphic for a larger class of groups may salvage more information. For instance, it is not hard to show (though a bit tricky) that for finite groups $A,B$ if the hom sets (not hom groups even, just the sets) are isomorphic for all finite groups $G$, then the two groups must be isomorphic. This fails for infinite groups, though the same result is recovered if one requires the hom sets to be naturally isomorphic for all groups $G$. This result is just a special case of an elementary result in category theory about representability. 
