WORKS!

Unless you have duplicates. Took me half an hour to figure that out.