#heapq
Finding the Largest or Smallest N Items
The heapq module has two functions—nlargest() and nsmallest()
✍️ note that If you are simply trying to find the single smallest or largest item (N=1), it is faster to use min() and max()
source: "python cookbook" 3rd edition
Post #74
324
