Shabbos 152a: Rav Yehuda said: If someone dies and has no relatives to sit shiva, ten people should go to his place and sit shiva for him.
שבת קנב ע”א: אמר רב יהודה מת שאין לו מנחמין הולכין י’ בני אדם ויושבין במקומו.
Rabbi Simcha Wasserman and his Rebbetzin were not blessed with children. The Rebbetzin at first used to say she hoped to predecease Reb Simcha so that she shouldn’t have to live without him. Then she changed her mind and said, let me outlive him so that I can sit shiva for him. In the end, she passed away exactly nine days after him.
Source: A Canopy of Stars
[We see here that aveilus is not just for the aveilim; it’s for the niftar. That is why the Gemara says that if there are no aveilim, ten people should go and sit shiva. And by the same token, the Rebbetzin wanted Reb Simcha to have someone to sit shiva for him. See my notes on the story “Learning Torah is Better than Kaddish” brought on Sanhedrin 104a, where it seems that this is a dispute between the Rambam and the Ramban.
In fact, in Yoreh Deah 376:3 the Mechaber quotes our Gemara (that ten people should sit shiva), and the Rema comments that he has not seen people do this; however, there is a minhag to hold daily minyanim in the niftar’s house for seven days. It could be that the Gemara and the Mechaber are going with the opinion that aveilus is for the niftar, while the Rema is going with the opinion that aveilus is for the aveilim.]