What is the complexity of the function most_common provided by the collections.Counter object in Python?
More specifically, is Counter keeping some kind of sorted list while it's counting, allowing it to perform the most_common operation faster than O(n) when n is the number of (unique) items added to the counter? For you information, I am processing some large amount of text data trying to find the n-th most frequent tokens.
I checked the official documentation and the TimeComplexity article on the CPython wiki but I couldn't find the answer.
 
     
     
    