After greeting Allah, it is then prescribed for the slave to send greetings upon all the righteous slaves of Allah – the persons whom Allah has favoured and chosen. This part of the greeting is positioned right after the greetings and praise of Allah, in conformation to the order mentioned in the ayah, “Say [O Muhammad]: ‘Praise be to Allah, and peace be upon His servants home He has chosen.” (Surah Al-Naml 27:59) Not to mention that since it is a greeting intended for the created, (therefore as a matter of etiquette) it should not precede the greetings addressed to the Creator.
Within the greeting intended for His righteous slaves, Allah has prescribed that they be addressed in order of the ranks of the recipients, so that the first to be greeted is the one who deserves it the most: the Messenger of Allah, peace and blessings of Allah be upon him, whose nation received every form of good through him. The second person to be greeted is the slave himself, followed by the rest of the pious slaves of Allah, the best among whom are the Prophets and Angels followed by the Companions of the Prophet and then the followers of all the Prophets, and all the righteous slaves occupying the heavens and earth. At the end, it is prescribed for him to send salutations of peace upon all those who deserve to be greeted, in particular and in general.
Inner Dimensions of the Prayer by Ibn Qayyim Al-Jawziyyah Pages 62-63