This is similar to Birds of a feather flock together.
Benjamin Hapgood Burt, the American lyricst, wrote the following delightful jingle:
One evening in October
When I was far from sober,
And dragging home a load with manly pride,
My feet began to stutter,
So I laid down in the gutter,
And a pig came up and parked right by my side.
Then I warbled, ‘Its’s fair weather
When good fellows get together’,
Till a lady passing by was heard to say :
‘You can tell a man who boozes
By the company he chooses’.
And the pig got up and slowly walked away.