The young should salute the old, the one who is passing by should salute the one who is sitting, and a small company should salute a large one.
Sunan Abi Dawud Book 43, Hadith 426