I'm new to python and I'm having trouble trying to sort a list correctly. I have a map of strings->Word objects. A word object contains a list of all the places in a file where the word occurs. So in the Word class I have this method:
def _cmp_(self,other): print'here' return other.num_occurences()-self.num_occurences()
Then elsewhere I have this code:
values = map.values()#list of Word objects values.sort()#need to sort based on length of occurences
But it isn't sorting based on the cmp method. I put that print statement in the cmp method so that if values.sort() called the cmp method it would print 'here' but nothing prints.