Given an dictionary with lists as values this piece of code is dedicated to find the n keys with the longest lists as values. It works, but there has to be a more elegant solution.def get_n_longest_values(dictionary, n):    result = []    for key, value in dictionary.items():        if len(result) < n:            result.append((key, len(value)))        else:            # (index, length) of smallest element            smallest = (10e10, 10e10)            for index in range(0, n):                if result[index][1] < smallest[1]:                    smallest = (index, result[index][1])            if len(value) > smallest[1]:                result[smallest[0]] = (key, len(value))    return result
Python 3 - Get n greatest elements in dictionary
python;algorithm;python 3.x;search;dictionary