The Messenger of Allah ﷺ was asked, "Who is the noblest of people?"He replied, "The most God-conscious of them."They said, "That is not what we are asking you about."He said, "Then it is Yusuf, the prophet of Allah, son of the prophet of Allah, son of the prophet of Allah, son of the friend of Allah."They said, "That is not what we are asking you about."He said, "Then you are asking me about the origins of the Arabs. The best of them in the days of ignorance are the best of them in Islam, provided they gain understanding of the religion."
حدثنا يحيى عن عبيد الله قال حدثني سعيد عن أبيه
سئل رسول الله ﷺ من أكرم الناس قال أتقاهم قالوا ليس عن هذا نسألك قال فيوسف نبي الله ابن نبي الله ابن نبي الله ابن خليل الله قالوا ليس عن هذا نسألك قال فعن معادن العرب تسألوني خيارهم في الجاهلية خيارهم في الإسلام إذا فقهوا
Its isnad is sahih. Bukhari related it, 6/387, no. 3353, Fath, Beginning of Creation, on the words of the Almighty, "And Allah took Ibrahim as a close friend" [Nisa 4:125], and Muslim, 1/84, no. 223, in the Introduction, chapter on following the scholars. It has already occurred at 2/391.