كتاب المقدمات
The Book of Miscellany
(44)
Chapter: Revering the Scholars and Elders, Preferring them to others and raising their Status
(44)
- باب توقير العلماء والكبار وأهل الفضل وتقديمهم على غيرهم، ورفع مجالسهم، وإظهار مرتبتهم
Riyad as-Salihin 350
'Abdullah bin Mas'ud (May Allah be pleased with him) reported:
Messenger of Allah (ﷺ) said, "Let those be nearest to me in Salat (prayer) who are mature and possess (religious) knowledge, then those who are nearest to them in these respects". He repeated this three times and then added, "Beware of indulging in the loose talks of the markets (when you are in the mosque)".

[Muslim].

وعن عبد الله بن مسعود رضي الله عنه قال‏:‏ قال رسول الله صلى الله عليه وسلم‏:‏ ‏"‏ليلني منكم أولو الأحلام والنهى، ثم الذين يلونهم‏"‏ ثلاثًا ‏"‏وإياكم وهيشات الأسوق‏"‏ ‏(‏‏(‏رواه مسلم‏)‏‏)‏‏.‏
Reference : Riyad as-Salihin 350
In-book reference : Introduction, Hadith 350