The appropriate answer to this question depends on the circumstances and context. Generally, the most polite way to greet people is to greet those who are most senior first. In a business setting, this may mean greeting the most tenured employees, practitioners of higher ranks or senior management first.
For example, if you are in a dinner party, it is polite to greet the host or hostess first. In a professional setting, clients, customers, and visitors may also be greeted first.
In social settings outside of work, it is polite to greet the oldest, most respected, or most important people in the group first. For example, one might greet parents, or a very important guest first.
If you are unsure of the hierarchy of the group present, it is polite to simply say: “Good morning/afternoon/evening everyone!”