Surah Al-Anfal 8:37
لِيَمِيزَ ٱللَّهُ ٱلْخَبِيثَ مِنَ ٱلطَّيِّبِ وَيَجْعَلَ ٱلْخَبِيثَ بَعْضَهُۥ عَلَىٰ بَعْضٍ فَيَرْكُمَهُۥ جَمِيعًا فَيَجْعَلَهُۥ فِى جَهَنَّمَ ۚ أُو۟لَـٰٓئِكَ هُمُ ٱلْخَـٰسِرُونَ
[It is] so that Allāh 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.
Translation: Saheeh International
Tafsir
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.
Excerpt from Tafsir al-Jalalayn, commentary on 8:37, via Quran.com. The reader has the full commentary and 9 more tafsirs.