How do I remove all duplicates from list and order it based on count?
s = ["foo", "this", "lem", "foo", "lem"] s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"] #should return >>> ["foo", "lem", "this"] >>> ["ebh", "wosv", "foo", "4whcu"]
- Must be shorter than the below code in terms of byte size.
- Order must be based on the count of in descending order.
- If there are two strings with the same count, the first appearance comes first
- All duplicates must be removed, only one of each string should be in the final list
I currently have
I've noticed answers like
set but that arbitrarily changes the order, which I do not want.
Edit: Sorry for the poor quality before. I had whipped this right before I slept and I was quite tired. This is not for StackOverflow because I'm trying to golf/shorten the size of this code as much as possible. I've tried looking for answers but I haven't been able to find anything.