The Messenger of Allah ﷺ said, "When Allah sends down a punishment upon a people, it strikes everyone among them, and then they are resurrected according to their deeds."
حدثنا إبراهيم بن إسحاق حدثنا ابن المبارك عن يونس عن ابن شهاب أخبره حمزة بن عبد الله بن عمر أنه
قال رسول الله ﷺ إذا أنزل الله بقوم عذابا أصاب العذاب من كان فيهم ثم بعثوا على أعمالهم
Its isnad is sahih. Ibrahim bin Ishaq is Talaqani, whose reliability was established previously at 1596, and we add here that Bukhari included his biography in Al-Kabir 1/1/273 and Al-Sagheer 233. The hadith is a repeat of 4985.