Separate the sheep from the goats
Separate the good from the bad.
This expression derives from the Bible, Matthew 25 and is first found in print in Miles Coverdale's Bible, 1535:
25:31 But whan the sonne of man shal come in his glory, and all holy angels with him, then shal he syt vpon the seate of his glory.
25:32 And all people shalbe gathered before him: and he shal separate them one from another as a shepherde deuydeth the shepe from ye goates.
25:33 And he shal set ye shepe on his right honde, and the goates on the lefte.
Both sheep and goats were valuable farm animals in ancient Palestine. The verses in Matthew use the commonplace Christian imagery that portrays them in very different lights. Sheep are depicted as the meek and gentle followers of Christ (the Lamb of God) and goats as unruly and coarse outcasts, who are otherwise castigated as scapegoats and widely used as the basis of portraits of Satan.
The figurative use of the biblical text didn't arise in until the late 19th century; for example, in this tongue-in-cheek advertisement for a drapery store, in the Modesto Daily Evening News, June 1895:
The Foolish Woman:
Sayeth in her heart there is no such thing as a bargain to be had in all the city of Modesto.
The Wise Woman:
Knoweth better. She discerneth the sheep from the goats and understandeth that such in not the case. She scanneth the EVENING NEWS and when an announcement appears from MARRIOTT'S STORE she makes-haste to avail herself of any bargains he may have.