Hello!
So I'm wondering how to get this to sort them with the proper grouping, because the code below returns the first set with the 2's in between the 6's. I expect I'll need to add more in later to find a way to cope with the empty list, but at the moment I'm wondering what the easiest way to get it to have the right kind of grouping would be.
def frequencysort(items):
newlist = sorted(items, key= items.count, reverse=True)
return new_list
Example:
[4, 4, 4, 4, 6, 2, 2, 6]
Created at: 2020/01/05 23:52; Updated at: 2021/10/22 22:10