כֹּהֵן קוֹדֵם לְלֵוִי, לֵוִי לְיִשְׂרָאֵל, יִשְׂרָאֵל לְמַמְזֵר, וּמַמְזֵר לְנָתִין, וְנָתִין לְגֵר, וְגֵר לְעֶבֶד מְשֻׁחְרָר. אֵימָתַי, בִּזְמַן שֶׁכֻּלָּן שָׁוִין. אֲבָל אִם הָיָה מַמְזֵר תַּלְמִיד חָכָם וְכֹהֵן גָּדוֹל עַם הָאָרֶץ, מַמְזֵר תַּלְמִיד חָכָם קוֹדֵם לְכֹהֵן גָּדוֹל עַם הָאָרֶץ:
Un cohen passe avant le lévite, celui-ci passe avant d’autres Israélites; ceux-ci passent avant un bâtard. Le bâtard passe avant le nathin, celui-ci passe avant l’étranger prosélyte, lequel passe avant l’esclave affranchi. Toutes ces préférences se rapportent aux hommes qui ne se distinguent entre eux par aucune autre chose. Mais si le bâtard est un savant, et si le grand prêtre est un ignorant, le savant bâtard passe avant le grand prêtre ignorant.
Bartenura
כהן קורא ראשון – When they are equal in wisdom, but if the Israelite is greater in wisdom, he precedes the Kohen and the Levite (see Mishnah Horayot, Chapter 3, Mishnah 8) for a Sage who is illegitimate comes before a High Priest who is an ignoramus. The law is the law of the Gemara, but today it is the practice that the Kohen, even if he is an ignoramus, comes before a great Sage who is an Israelite.
Binyan Yehoshua
That a mamzer does not enter Jerusalem. Even though it says at the end of Tractate Horayot (Horayot 3:8) that a learned mamzer precedes an ignoramus high priest. As it says (Proverbs 3:15) "She [wisdom] is more precious than rubies", from a high priest who enters within and beyond. Nonetheless, the holiness of Jerusalem is unable to bear him, since its holiness is very great -- one who does not have proper lineage, such as a mamzer, would not be able to have settlement in Jerusalem. And so it is written "And a mamzer shall dwell in Ashdod, etc." (Zechariah 9:6). Commentated.