Find N largest or lowest values with heapq
You have a collection of items and you need to keep the N highest or lowest of them. Instead of writing your own algorithm, use build-in heapq module.
This module has two handy functions, nlargest(), and nsmallest().
This is...