Jami` at-Tirmidhi, Book 42, Hadith 19 (Tirmidhi 2776)

Narrated Abu Hurairah:

that the Messenger of Allah (ﷺ) said: "When one of you arrives at the gathering, then give the Salam, and if he is given a place to sit, then let him sit. Then when he stands, let him give the Salam, the first is more worthy than the last."