I have a problem with my sorting method.
This is my object contained in list: Address class, with city attribute
My list looklike (simplified) :
[Address('Paris'), Address('Denver'), Address('Paris'), Address('Test'), Address('Denver')]
For this example, i have two duplicates cities: Paris and Denver,
I want to have a result like:
[Address('Devenr'), Address('Denver'), Address('Paris'), Address('Paris'), Address('Test')]
Sorted by duplicates count, and in case of same number, by alphanumeric order.
I tried:
self.dictionnary.sort(key=lambda address: len([x for x in self.dictionnary if address.city == x.city]))
By this don't work...
Can anyone help me?
Thank you in advance !