I know of two approaches to it. The first one: documentation is [here](https://docs.python.org/3/library/heapq.html#heapq.nlargest)

```
heapq.nlargest(n, iterable, key=None)

```

and the second traditional approach of using sorted

```
sorted(iterable, key=key, reverse=True)[:K]

```

The documentation mentions that these two are equivalent. However, I just wanted to know if the complexity of both are the same or if the first approach was implemented with lesser time complexity. 

I remember from my algorithms course that obtaining top K elements from a list can be done in lesser order of operations compared to sorting the entire list and then going with picking the top K.
Correct me if I am wrong

**Edit:** What standard python libs can perform this task in O(N) operations or what's the best complexity we can get from python?