Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:8:37

˹This is˺ so that Allah may distinguish the wicked from the good and place the wicked some of them upon others and heap them all together and put them into Hell. It is those who are the losers.  

that God may distinguish (read li-yamīza, or li-yumayyiza, is semantically connected to takūnu, ‘it will be’ ˹from the previous verse˺) the wicked, the disbeliever, from the good, the believer, and place the wicked one upon another, and heap them up all together and put them in Hell: those, they are the losers.
القرآن:٨:٣٧

لِيَمِيزَ اللَّهُ الْخَبِيثَ مِنَ الطَّيِّبِ وَيَجْعَلَ الْخَبِيثَ بَعْضَهُ عَلَىٰ بَعْضٍ فَيَرْكُمَهُ جَمِيعًا فَيَجْعَلَهُ فِي جَهَنَّمَ ۚ أُولَٰئِكَ هُمُ الْخَاسِرُونَ  

{ليميزَ} متعلق بتكون بالتخفيف والشديد أي يفصل {الله الخبيث} الكافر {من الطيب} المؤمن {ويجعل الخبيث بعضه على بعض فيَرْكُمَهُ جميعا} يجمعه متراكما بعضه على بعض {فيجعله في جهنَّم أولئك هم الخاسرون}.