It is narrated from Abdullah bin Yasar (may Allah have mercy on him) that Sayyiduna Amr bin Hurayth (may Allah be pleased with him) visited Sayyiduna Hasan bin Ali (may Allah be pleased with them both) when he was ill, and Sayyiduna Ali (may Allah be pleased with him) said to him: "Are you visiting Hasan while there is in your heart (concerning us) what there is?" Sayyiduna Amr (may Allah be pleased with him) said to him: "Indeed, you are not my Lord, that you can turn my heart wherever you wish." Sayyiduna Ali (may Allah be pleased with him) said: "Know that this does not prevent us from conveying a word of sincere advice to you; I heard the Messenger of Allah (peace and blessings be upon him) saying: 'There is no Muslim who visits his Muslim brother but that Allah Almighty sends seventy thousand angels for him, who keep praying for mercy for him, whatever hour of the day he visits, until evening comes, and whatever hour of the night he visits, until morning comes.'"
Sayyiduna Amr (may Allah be pleased with him) asked him: "What do you say about walking in front of the funeral or behind it?" Sayyiduna Ali (may Allah be pleased with him) said: "The virtue of walking behind it over walking in front of it is like the virtue of offering the obligatory prayer in congregation over praying alone."
Sayyiduna Amr (may Allah be pleased with him) said: "But I have seen Sayyiduna Abu Bakr and Sayyiduna Umar (may Allah be pleased with them both) walking in front of the funeral?!" Sayyiduna Ali (may Allah be pleased with him) said: "They both (by walking in front) disliked putting the people into hardship or difficulty (by making them think that walking behind was obligatory)."
Ishaq bin Rahwayh (may Allah have mercy on him) narrated it in his "Musnad" from al-Nadr bin Shumayl (may Allah have mercy on him), from Hammad bin Salamah (may Allah have mercy on him).
And Ibn Hibban al-Busti (may Allah have mercy on him) narrated it up to the word "yusbiha" (until morning comes) from Imran bin Musa (may Allah have mercy on him), from Hudbah bin Khalid (may Allah have mercy on him), from Hammad bin Salamah (may Allah have mercy on him).
Related hadith on this topic