Beings come together and associate according to disposition. Those with wrong views come together and associate with those with wrong views, and similar for the other eight factors. Those with right views come together and associate with those with right views, and similar for the other eight factors.
Aṭṭhaṅgika sutta - The Eightfold Path
"Bhikkhus, beings come together and associate according to disposition. Those with wrong views come together and associate with those with wrong views; those with wrong intentions come together and associate with those with wrong intentions; those with wrong speech come together and associate with those with wrong speech; those with wrong actions come together and associate with those with wrong actions; those with wrong livelihood come together and associate with those with wrong livelihood; those with wrong effort come together and associate with those with wrong effort; those with wrong mindfulness come together and associate with those with wrong mindfulness; those with wrong collectedness come together and associate with those with wrong collectedness.
Those with right views come together and associate with those with right views; those with right intentions come together and associate with those with right intentions; those with right speech come together and associate with those with right speech; those with right actions come together and associate with those with right actions; those with right livelihood come together and associate with those with right livelihood; those with right effort come together and associate with those with right effort; those with right mindfulness come together and associate with those with right mindfulness; those with right collectedness come together and associate with those with right collectedness."