Sutra 33, book 1 of Yoga Sutras of Patanjali
Maitri karuna muditopeksanam sukha duhkha punyapunya visayanam bhavanatas citta prasadanam
By cultivating attitudes of friendliness toward the happy, compassion for the unhappy, delight in the virtuous and disregard toward the wicked, the mind-stuff retains its undisturbed calmness.
Keeping a peaceful mind in our daily life is essential and highly desirable by all of us no matter what is our background or aspirations and inspirations. Master Patanjali talks about 4 keys (friendliness, compassion, delight, and disregard) here used to unlock the four locks. Sukha, duhka, punya, apunya - happy people, unhappy people. the virtuous and the wicked. At any given moment you can fit a person in these four categories.
So when acquainted with the happy, we should use the friendliness key - otherwise being happy with and for the happiness of others. By our jealousy we won't disturb the other person, but rather our own serenity will be shaken. Being friendly and non judgemental will actually bring calm and acceptance upon us. Feeling compassion for the unhappy and extending our mercy towards them is important to set our mind at peace. Our mercy might not necessary reach the ones in need, but we will be helped by it. For the virtuous, one should feel delight. They could become inspiration, role model, cultivating the beauty you see in others within yourself. Last but not least, the wicked. You should be indifferent to them. Advising them is never beneficial as it is often taken as a personal insult toward them. And what we should ponder on sometimes is that often we could act wicked as well due to anger and frustration. And today may be we are ok - but who knows how we will be tomorrow? The same goes for others. If we keep on reminding ourselves about these keys and using them wisely, our serenity will be nourished. Our minds peaceful.
Deliberation and quotes above are based on commentary by Swami Satchidananda.