Assalamualaikum ustaz. How did the companions R.Anhum perform the funeral prayer of the Rasullullah PBUH?
Waalaikumussalam wrt. wbt.,
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions, and all those who follow his footsteps until the Final day.
The death of the Prophet PBUH was the gravest disaster for the Muslim ummah. The world suddenly went dark and uncertain for the companions R.Anhum when they received the news of the Prophet PBUH’s death. Anas bin Malik RA said:
لَمَّا كَانَ الْيَوْمُ الَّذِي دَخَلَ فِيهِ رَسُـولُ اللهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ الْمَدِينَةَ؛ أَضَاءَ مِنْهَا كُلُّ شَـيْءٍ، فَلَمَّا كَانَ الْيَوْمُ الَّذِي مَاتَ فِيهِ؛ أَظْلَمَ مِنْهَا كُلُّ شَيْءٍ، وَمَا نَفَضْنَا عَنْ رَسُولِ اللهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ اْلأَيْدِي -وَإِنَّا لَفِي دَفْنِهِ- حَتَّى أَنْكَرْنَا قُلُوبَنَا.
“On the day when the Messenger of Allah (ﷺ) entered Al-Madinah, everything was lit up, and on the day when he died, everything went dark, and no sooner had we dusted off our hands (after burying him) but we felt that our hearts had changed.” 
Al-Hafiz Ibn Hajar said: “It means they found their hearts changed from before when Rasullullah PBUH was still with them in the form of clarity and softness. The reason is they have lost everything given by the Prophet PBUH in terms of education and teaching.” 
Hasan bin Thabit expresses his feelings about the death of Rasullullah PBUH in the form of a poem. Among others he said:
أطَالَتْ وُقُوفًا تَذْرِفُ الْعَيْنَ جُهْدَهَا عَلَى طَلَلِ الْقَبْرِ الَّذِي فِيْهِ أَحْمَدُ
لَقَدْ غَيَّبُوا حُلْمًا وَعِلْمًا وَرَحْمَةً عَشِيَّةَ عَلَّوْهُ الثَّرَى لَا يُوَسَّدُ
وَرَاحُوا بِحُزْنٍ لَيْسَ فِيْهِمْ نَبِيُّهُمْ وَقَدْ وَهَنَتْ مِنْهُمْ ظُهُورٌ وَأعْضُدُ
يُبَكّونَ مَنْ تَبْكِي السّمَوَاتُ يَوْمَهُ وَمَنْ قَدْ بَكَتْهُ الْأرْضُ فَالنّاسُ أكْمَدُ
وَهَلْ عَدَلَتْ يَوْمًا رَزِيّةُ هَالِكٍ رَزِيّةَ يَوْمٍ مَاتَ فِيهِ مُحَمّدُ؟
There I stand unmoving, tears in an endless flow,
Looking at the pile of dirt where Ahmad now lies (Muhamamd PBUH)
Gone is the person who loves the most, with waves of knowledge and blessings following him,
On the evening dirt covered the body of the Prophet PBUH, lying there with no pillows,
One by one each person left in sadness and grieve, the Prophet no longer by their sides,
Their backs and knees weakened,
Endless grieve, continuous tears and the skies also cried that day,
So did the earth, it cries as people were bewildered,
Is there any greater calamity and sadness?
Comparable to the day of the death of the Prophet Muhammad PBUH? 
Coming back to the above question, the funeral prayer sanctioned in Islam is as stated in numerous evidences, among them is a hadith from Abu Hurairah RA, he said:
أَنَّ رَسُولَ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ نَعَى النَّجَاشِىَّ فِى الْيَوْمِ الَّذِى مَاتَ فِيهِ، خَرَجَ إِلَى الْمُصَلَّى، فَصَفَّ بِهِمْ وَكَبَّرَ أَرْبَعًا
The Prophet gave the people news of the death of the Negus on the day on which he died, took them out to the place of prayer, drew them up in rows and said “God is most great” four times.” 
In answering the above question, there is evidence from the book al-Muwatta’ that states:
وَصَلَّى النَّاسُ عَلَيْهِ أَفْذَاذًا لاَ يَؤُمُّهُمْ أَحَدٌ
“And people prayed for the Prophet PBUH one by one alone. Without any one of them being an imam for others.” 
Likewise, this is also stated by Imam al-Baihaqi from Ibn Abbas, Ibn Sa’d from Sahl bin Sa’d and from Ibn al-Musayyib and others.
In a narration by al-Tirmizi, people asked Abu Bakar RA: “Should we perform the funeral prayer for Rasullullah PBUH?” Abu Bakar then answered: “Yes.” They asked: “How should we pray?” Abu Bakar answered: “One group will enter. They perform takbir and pray and supplicate. Then another group will enter, they’ll perform takbir, pray and supplicate each on their own.”
From Ibn Sa’d from Ali RA, he said: “He (Rasullullah PBUH) is your imam whether when he was alive or after his death. Hence, nobody can precede him.” This is stated by al-Zurqani. 
Syeikh Sofiyyurahman stated in al-Rahiq al-Makhtum: People entered into the room in turns, ten people prayed for the Rasullullah PBUH, without anyone being the imam. The first turn to perform the funeral prayer is his family members, then the Muhajirin, then the Ansar. After the men, the women prayed then followed by children.
All of these were performed in a day, from a Tuesday until Wednesday. Aisyah said: “We didn’t know of when the funeral of Rasullullah PBUH was until we heard the sound of the hoe on Wednesday night.” 
O Allah, we love Your Messenger. Make us from amongst those who earn Your paradise! Amin.
 Narrated by al-Tirmizi (3618), Ibn Majah (1631) and Ahmad (13830). Syeikh Syu’aib al-Arnauth its isnad is sahih.
 See Fath al-Bari, 8/149
 See al-Sirah al-Nabawiyyah by Ibn Hisyam, 6/90; al-Sirah al-Nabawiyyah by Ibn Kathir, 4/557 and al-Iktifa’ bima Tadhammanahu min Maghazi Rasulillah, 2/371
 Narrated by al-Bukhari (1188) and Muslim (951)
 See al-Muwatta’, 1/316
 See Awjaz al-Masalik ila Muwatta’ Malik, 8/500
 See al-Rahiq al-Makhtum, pg. 688