heapq.nsmallest()

heapq.nsmallest(n, iterable, key=None)[source]

Find the n smallest elements in a dataset.

Equivalent to: sorted(iterable, key=key)[:n]