The requirement seems to contain a contridiction, count the number of unique strings, sort them according to how many times they appear. But if a string appear more than once it's not unique.