Sayyiduna Uqbah bin Amr (Abu Mas'ud) (may Allah be pleased with him) said: the Messenger of Allah (peace and blessings be upon him) used to say: "Let those of you who have intellect and understanding stand closest to me, then those who come after them, then those who come after them."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 14665