The Messenger of Allah ﷺ said, "When Allah sends down punishment upon a people, it strikes everyone among them, then they will be resurrected according to their deeds."
قال رسول الله ﷺ: إذا أنزل الله بقوم عذابا، أصاب العذاب من كان فيهم، ثم بعثوا على أعمالهم.
Bukhari narrated it in the Book of Tribulations (7108), and Muslim narrated it in the Book of the Description of Paradise and Hellfire (2879), both from the hadith of Yunus, from Zuhri, who said, Hamza bin Abdullah bin Umar informed me that he heard Ibn Umar, and he related it, and their wording is the same.